Institute: Uie Department: Cse: Bachelor of Engineering (Computer Science & Engineering)
Institute: Uie Department: Cse: Bachelor of Engineering (Computer Science & Engineering)
DEPARTMENT : CSE
Bachelor of Engineering (Computer Science &
Engineering)
2
Multithreading
Java's multithreading functionality
enables two or more application
components to
run concurrently for optimal CPU
utilization.
• Context switching from one process to another is a CPU intensive task needing more time.
These are the reasons why processes are referred to as heavyweight tasks
Multitasking Vs. Multithreading (cont...)
– Multiple threads in a program share the same address space and they are
part of the same process
It is
accomplished
by having each
activity
performed by a
separate thread Threads are the
A multithreaded
application lightest tasks within a
performs two or program, and they
more activities share memory space
concurrently and resources with
each other
QUIZ
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.
Advantages of a Multithreaded Application
Video Links:
https://youtu.be/O_Ojfq-OIpM
https://youtu.be/JceAHRlQsqc
Reference Links:
https://www.geeksforgeeks.org/lifecycle-and-states-of-a-thread-in-java/
https://www.journaldev.com/1044/thread-life-cycle-in-java-thread-state
s-in-java
https://www.iitk.ac.in/esc101/05Aug/tutorial/essential/threads/lifecycle.
html
https://www.decodejava.com/life-cycle-of-thread.htm
THANK YOU