Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Difference between Process and Thread in Java

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 214
    Comment on it

    Difference between Process and Thread : A process is an executing instance of an application, it can be seen as a program or application. It has it's own memory space and resources. A thread is a lightweight process, it can be seen as a part of a process. Every process has at least one thread called primary thread. A thread can do everything a process can do.

    For example : When we click on a Microsoft word icon a process will start. Now after writing something on it when we give print then one thread will be created and it prints the document while you can write new document or can do any other work on document.

    Threads runs in the background as a part of the process. A process can have more than one threads. The difference between the Process and Threads are as follows :

    1. It is helpful to create a thread instead of creating a separate process, because process needs a separate address space but thread don't.
    2. Multi-threading is little hard and requires programming carefully since thread shares the data and resources, so it is the challenge for the programmer that data should be consistent for all threads. While in the case of Process every process has it's own space and resources so programmer don't need to worry so much about data consistency.
    3. A process can contains as many threads that's why process called heavyweight and thread called lightweight because threads uses less resources than process.
    4. Each processes is independent to each other while threads are interdependent to other threads since they shares the same address space.
    5. Threads have permission to access the data of it's parent process while the process can not directly access the data of it's parent process.
    6. A process always has it's own execution environment and memory space while thread runs under the process and shared space and resources.
    7. Context switching between processes is more expensive than between threads.
    8. Thread intercommunication is relatively easy than process communication.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: