2017  Kodetalk | Feedback | Privacy Policy | Terms | About

What is the basic difference between thread and process in java

I am new and not able to visualize the basic difference between a thread and process. Please explain?


In a single statement a process can have multiple Threads and a Thread is a subdivision of Process. One or more Threads runs in the context of process. Threads can execute any part of process or another way we can say process can be executed by multiple Threads. Processes used to have their own copy of the data segment of the parent process while Threads have direct access to the data segment of its process. Processes have their own address while Threads share the address space of the process that created it. Thread can be easily created for processing a small part of Process. Threads can easily communicate with other threads of the same process using wait() and notify() methods. In process all threads share system resource like heap Memory etc. while Thread has its own stack. Any change made to process does not affect child processes, but any change made to thread can affect the behavior of the other threads of the process.

Answer is