4.1 Java
4.1 Java
Sneha D. Patil
(Assistant Professor)
E&C department
INDEX
INTRODUCTION TO MULTITHREADING
ADVANTAGES
MULTITASKING
TYPES OF MULTI TASKING
WHAT IS THREAD
Life Cycle of a Thread in Java Multithreading
INTRODUCTION TO
MULTITHREADING
Multithreading in Java is a process of
executing multiple threads simultaneously.
A thread is a lightweight sub-process, the
(Multiprocessing)
Thread-based Multitasking (Multithreading)
Process-based Multitasking
(Multiprocessing)
is high.
Switching from one process to another
is low.
What is Thread in java
A thread is a
lightweight subprocess,
the smallest unit of
processing. It is a
separate path of
execution.
Threads are
independent. If there
occurs exception in one
thread, it doesn't affect
other threads. It uses a
shared memory area.
Life Cycle of a Thread in Java Multithreading
STAGES OF LIFECYCLE
New − A new thread begins its life cycle in the new state. It
remains in this state until the program starts the thread. It is also
referred to as a born thread.
Runnable − After a newly born thread is started, the thread
becomes runnable. A thread in this state is considered to be
executing its task.
Waiting − Sometimes, a thread transitions to the waiting state
while the thread waits for another thread to perform a task. A
thread transitions back to the runnable state only when another
thread signals the waiting thread to continue executing.
Timed Waiting − A runnable thread can enter the timed waiting
state for a specified interval of time. A thread in this state
transitions back to the runnable state when that time interval
expires or when the event it is waiting for occurs.
Terminated (Dead) − A runnable thread enters the terminated
state when it completes its task or otherwise terminates.
TO BE CONTINUE…..