The real difference between Process and Thread in Java ?
One of the common question from programming interviews is, what is the difference between a Thread and a Process? Well,
the main difference between them is that a Process is a program which is executing some code and a thread is an independent path of execution inside the process.
A process can have more than one thread for doing independent task e.g. a thread for reading data from disk, a thread for processing that data and another thread for sending that data over the network. This technique to improve throughput and better utilize CPU power is also known as multi-threading.
Technically, most significant difference between thread is address space and context switching. All thread from a process share same address space but a process has their own address space. Similarly, context switching between process is more expensive than context switching between threads.
the main difference between them is that a Process is a program which is executing some code and a thread is an independent path of execution inside the process.
A process can have more than one thread for doing independent task e.g. a thread for reading data from disk, a thread for processing that data and another thread for sending that data over the network. This technique to improve throughput and better utilize CPU power is also known as multi-threading.
Technically, most significant difference between thread is address space and context switching. All thread from a process share same address space but a process has their own address space. Similarly, context switching between process is more expensive than context switching between threads.
Comments
Post a Comment