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

Java Multithreading Overview

Multithreading in Java allows concurrent execution of parts of a program to make use of CPU resources. It uses lightweight processes called threads that can run independently and exist in different states like new, runnable, suspended, blocked, and terminated. Threads can be created by implementing the Runnable interface or extending the Thread class and executing single or multiple tasks from single or multiple threads to improve efficiency.

Uploaded by

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

Java Multithreading Overview

Multithreading in Java allows concurrent execution of parts of a program to make use of CPU resources. It uses lightweight processes called threads that can run independently and exist in different states like new, runnable, suspended, blocked, and terminated. Threads can be created by implementing the Runnable interface or extending the Thread class and executing single or multiple tasks from single or multiple threads to improve efficiency.

Uploaded by

Kaushik Ray
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Multithreading in Java can alternatively be

explained as a unique feature that uses


threads to speed up application execution. 

Multithreading is a feature in Java


that concurrently executes two or more
parts of the program for utilizing the CPU at
its maximum. The part of each program is
called Thread which is a lightweight process.

The Java Thread Model-Why


use Threads in Java?
The Java run-time system depends on threads
for many things. Threads reduce inefficiency by preventing the waste of CPU
cycles.

Threads exist in several states. Following are those states:  

 New – When we create an instance of Thread class, a thread is in a new


state.
 Runnable – The Java thread is in running state.
 Suspended – A running thread can be suspended, which temporarily
suspends its activity. A suspended thread can then be resumed, allowing
it to pick up where it left off.
 Blocked – A java thread can be blocked when waiting for a resource.
 Terminated – A thread can be terminated, which halts its execution
immediately at any given time. Once a thread is terminated, it cannot be
resumed. 
How to Create a Java Thread? 
Java lets you create thread in following two ways:- 

 By implementing the Runnable interface.
 By extending the Thread
[Thread creation by using Thread Class]

[Thread Creation using Runnable Interface]

Thread Execution Cases:

Case 1:Performing Single task from Single Thread


Performing Single task from Multiple Thread

Performing Multiple task from Multiple Thread

You might also like