Java Multi-Threading Question:
Download Job Interview Questions and Answers PDF
What is difference between thread and process?
Answer:
Process has its own memory address while the thread share the address of the process by which it is created.
Thread can access the data segment of its process directly while processes can access their own copy of the data segment of its parent process.
Threads have almost no overheads while processes may have overheads.
We can create a new thread easily but to create new process we have to duplicate the parent process.
If any changes in main thread are occurred it can affect the behavior of the other threads of the same process. While in case of process if any changes is occurred in parent process it won’t affect the behavior of parent process.
The direct communication is possible between threads of same process while in case of same sibling processes only interprocess communication is possible.
Thread can access the data segment of its process directly while processes can access their own copy of the data segment of its parent process.
Threads have almost no overheads while processes may have overheads.
We can create a new thread easily but to create new process we have to duplicate the parent process.
If any changes in main thread are occurred it can affect the behavior of the other threads of the same process. While in case of process if any changes is occurred in parent process it won’t affect the behavior of parent process.
The direct communication is possible between threads of same process while in case of same sibling processes only interprocess communication is possible.
Download Java Multi-Threading Interview Questions And Answers
PDF
Previous Question | Next Question |
What are the different states of a threads lifecycle? | What happens if we invoke run method without calling the start method for a thread instance? |