Java Multi-Threading Question:
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.
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? |