0% found this document useful (0 votes)
6 views34 pages

Java Multithreading Explained

The document discusses multithreading in Java, explaining that a multithreaded program contains multiple flows of control, with one main thread and others running concurrently. It highlights the concept of concurrency, the lightweight nature of Java threads, and the ability to execute multiple tasks simultaneously. Additionally, it touches on creating threads, extending the thread class, and the life cycle of a thread.

Uploaded by

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

Java Multithreading Explained

The document discusses multithreading in Java, explaining that a multithreaded program contains multiple flows of control, with one main thread and others running concurrently. It highlights the concept of concurrency, the lightweight nature of Java threads, and the ability to execute multiple tasks simultaneously. Additionally, it touches on creating threads, extending the thread class, and the life cycle of a thread.

Uploaded by

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

MULTITHREADING IN JAVA

DR. P. JEYANTHI
ASSISTANT PROFESSOR,
DEPARTMENT OF INFORMATION TECHNOLOGY
SRI RAMAKRISHNA COLLEGE OF ARTS & SCIENCE
MULTITHREADED PROGRAMMING
INTRODUCTION
• A program that contains multiple flows of
control is known as multithreaded program.
• Figure 12.2 illustrates a Java program with four
threads, one main and three others.
• The main thread is actually the main method
module, which is designed to create and start the
other three threads, namely A, B and C.
• Once initiated by the main thread, the threads A,
B, and C run concurrently and share the resources
jointly
• The ability of a language to support multithreads
is referred to as concurrency.
• Since threads in Java are subprograms of a main
application program and share the same memory
space, they are known as lightweight threads
or lightweight processes.
• 'Threads running in parallel' does not really mean
that they actually run at the same time.
• Since all the threads are running on a single
processor, the flow of execution is shared between
the threads.
• The Java interpreter handles the switching of
control between the threads in such a way that it
appears they are running concurrently.
• Multithreading is a powerful programming tool
that makes Java distinctly different.
• It enables programmers to do multiple things at
one time.
• They can divide a long program into threads
and execute them in parallel
CREATING THREADS
EXTENDING THE THREAD CLASS
EXTENDING THE THREAD
CLASS
• Example Program
LIFE CYCLE OF A THREAD
LIFE CYCLE OF A THREAD
22323
22323
THREAD METHODS
THREAD PRIORITY

You might also like