Friday, 22 April 2016

Process vs. Thread


Process vs. Thread

1. Thread is a single task of execution within the process.
     Process is a self contained execution environment and it can be seen as a program or application.

2. Threads share the address space of the process that  created it.
    Processes have their own address.

3. Threads have direct access to the data segment of its process.
    Processes have their own copy of the data segment of the parent process.

4. Threads can directly communicate with other threads of its process.
    Processes must use interprocess communication to communicate with sibling processes.

5. Threads have almost no overhead.
    Processes have considerable overhead.

6. New threads are easily created
    New processes require duplication of the parent process.

7. Threads can exercise considerable control over threads of the same process.
    Processes can only exercise control over child processes.

8. Changes to the main thread (cancellation, priority change, etc.) may affect the behavior of the other threads of the process

    Changes to the parent process do not affect child processes.


Examples
JRE runs as a single process which contains different classes and programs as processes.

Thread can be called lightweight process.

No comments:

Post a Comment

Note: only a member of this blog may post a comment.