elibraryportal Logo

Thread in Java

→ Thread is the smallest unit of program.

→ Each thread define a separate path for the execution.

→ In concurrent programming, there are two basic units of execution: process and threads.

→ A thread is a single sequential flow of control within a program. In other words. Some books use the name lightweight process instead of thread.

→ At a time one thread is executed only.


MultiThreading

→ MultiThrading is a conceptual program where, A program is divided into two ro more sub program.

→ All the sub program can be implemented in parallel

→ It is a process of executing multiple threads simultaneously.

→ MultiThreading is specialize from multitasking. Ther are Two type of multitasking.

Process Based Thread Based
This is the feature, that allow your computer to run two or more programs concurrently.In a thread based multitasking environment the thread is smallest unit of program.
Process(Program in execution) are heavy weight task that require there own separate address space.Thread are light weight. they share the same address space.
Inter process communication is expensive and limited.Inter thread communication is not expensive and context switching from one thread to another thread is also low cost.
Context switching from also one process to another costly.Thread is primitive .
Java program may use of process based multitasking environment.It is not under the control of java.Thread represents a module of the application.
Process is non primitive.
Process is exit in single state.
Process represents an application.
Thrad in java
Note

→ At a time one thread is executed only.