0% found this document useful (0 votes)
2 views3 pages

Java Multithreading Explained

Uploaded by

Techni Hemanth
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)
2 views3 pages

Java Multithreading Explained

Uploaded by

Techni Hemanth
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

THREADS

A thread is similar to sequential program. Every program has at least one thread that is called primary thread. We
can create more threads when necessary. A process having more than one thread is said to be multithreading.
In our system normally a single processor is doing only one process at a time. Multithreading helps to have maximum
use of CPU and minimizing the ideal time. This is useful for interactive, networked environment. Example: web browser
Thread is a built in class. It is in the package [Link]
Different states of a Thread

New Thread New born


stop()
start()

stop()
Active Thread Stop
Running Runnablee
yield()

sleep() stop()
wait() resume()
suspend( notify()
)

Idle Thread Blocked


Note: Multithreading in Java is a process of executing multiple threads simultaneously.
A thread is a lightweight sub-process, the smallest unit of processing. Multiprocessing and
multithreading, both are used to achieve multitasking.

Advantages of Java Multithreading


1) It doesn't block the user because threads are independent and you can perform multiple
operations at the same time.

2) We can perform many operations together, so it saves time.

3) Threads are independent, so it doesn't affect other threads if an exception occurs in a


single thread.

Multitasking

Multitasking is a process of executing multiple tasks simultaneously. We use


multitasking to utilize the CPU. Multitasking can be achieved in two ways:

o Process-based Multitasking (Multiprocessing)


o Thread-based Multitasking (Multithreading)

You might also like