- A program can be divided into two or more parts that can run concurrently and each part of such program is known as
- In a simple word,
threadis a lightweight sub-process.
- It is
a smallestunit of processing.
these threads execute concurrently foraccomplishing a task is known multithreading.
- In multithreading, each thread defines a separate path of execution.
- In multithreading, every thread has a priority between 1 to 10. Thread with
highestpriority getpreference over lower priority thread for execution.
In a java programming, Thread is a predefined class within a java.lang package.
Operating system (OS) can contain multiple
Difference between Process and Thread
|A process has their own virtual address space.||Threads are entities within a process it uses its virtual address space of process.|
|Two processes running on the same system at the same time do not uses address space.||Two threads running within a process uses the same address space.|
|Every process has its own data segment||All threads within the process uses the same data segment of process.|
|In multiprocessing, processes use inter process communication techniques to interact with other processes.||In multithreading, threads do not uses inter process communication techniques because they not uses separate address spaces. They share the same address space therefore, they can communicate directly with other threads within process.|
|Processes have considerable overhead.||Threads have almost no overhead;|
|Process is heavy weight.||Threads are light weight process (LWP).|
|Process contains much information about system, resource.||Threads carry less state information than process|
|When we create a child process from a parent process then it requires duplication of the resources of parent process.||No duplication of resources is required when we create a child thread from main thread.|