0% found this document useful (0 votes)
3 views6 pages

Understanding Java Multithreading

Uploaded by

Asiya Anjum S
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views6 pages

Understanding Java Multithreading

Uploaded by

Asiya Anjum S
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

MODULE 5

MULTITHREADED PROGRAMMING
Java Thread Model
The Java run-time system depends on threads for
many things, and all the class libraries are designed
with multithreading in mind.
The value of a multithreaded environment is best
understood in contrast to its counterpart.
Single-threaded systems use an approach called
an event loop with polling.
In this model, a single thread of control runs in an
infinite loop, polling a single event queue to decide
what to do next.
Once this polling mechanism returns with, say, a
signal that a network file is ready to be read, then the
event loop dispatches control to the appropriate
event handler.
Until this event handler returns, nothing else can
happen in the program.
This wastes CPU time.
The benefit of Java's multithreading is that the
main loop/polling mechanism is eliminated.
One thread can pause without stopping other parts
of your program.
When a thread blocks in a Java program, only the
single thread that is blocked pauses.
All other threads continue to run.

You might also like