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

Thread-Based Multitasking in Java

The document discusses multi-threading in Java, highlighting its ability to execute multiple threads simultaneously, enhancing application efficiency and saving time. It differentiates between process-based and thread-based multitasking, emphasizing that threads are lightweight and share memory, making them less expensive for communication. Additionally, it outlines the thread lifecycle, methods for using the Thread class, and the role of the thread scheduler in managing thread execution.

Uploaded by

nitinsingh3264
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)
7 views3 pages

Thread-Based Multitasking in Java

The document discusses multi-threading in Java, highlighting its ability to execute multiple threads simultaneously, enhancing application efficiency and saving time. It differentiates between process-based and thread-based multitasking, emphasizing that threads are lightweight and share memory, making them less expensive for communication. Additionally, it outlines the thread lifecycle, methods for using the Thread class, and the role of the thread scheduler in managing thread execution.

Uploaded by

nitinsingh3264
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

Multi - Threading

Friday, 4 July 2025 4:39 PM

Multi - threading ->

In Java , MT is a process of executing Multiple Threads simultaneously ->

Multiple Process -> Execution

Thread -> light weight sub process -> smallest unit of processing -> Multitasking ->

Live ex ->

Google meet
Screen
Voice
Zoom
Screen
Voice
Recording
Eclipse
Another Browser

Advantage ->
1. Does not block the user with the process
2. Can perform many operatioon together so that it can save time
3. Application efficiency enhance
4. Shares memory -> and resources together

Multi - threading + Multi - Processing -> Multi tasking

Item1 -> 4 min

Hotel

Item2 -> 3 min

Item3 -> 2 min

Multi - Tasking -> is a process of executing multiple task simultaneously , utilize CPU the more

1. Process - Based Multi tasking


i. Each process has an address in the memory
Multi - Tasking -> is a process of executing multiple task simultaneously , utilize CPU the more

1. Process - Based Multi tasking


i. Each process has an address in the memory
ii. Process -> heavy weight
iii. Cost of communication and data flow is expensive
iv. Switching from one process to another process -> requires some time for saving and
loading apps ->
2. Thread - Based Multi tasking
i. Thread share the memory address
ii. Thread light weight
iii. Cost of communication and data flow is not so expensive

What is a thread ->

Light weight subprocess


Smallest unit of processing
A+b P1
Separate path of execution
Independent kaam krtha hai
Block nhi krtha hai ->
Memory share
P2
A-b A/b

P3

OS

Java provides us a Thread class -> threading achieve ->

Life cycle ->

New -> thread created but not started


Runnable / Running -> thread is ready to run and waiting for CPU time
Waiting -> thread is waiting indefinitely for another thread to perform particular task
Terminated -> thread completed all the task

Thread ->
1. Start() -> used to start the execution
2. Run()
3. Sleep()
4. getPriority()
5. setPriority()
6. Interrupted()

To use Thread class ->

1. Extend Thread ->


2. By runnable interface -> Thread
To use Thread class ->

1. Extend Thread ->


2. By runnable interface -> Thread

Thread Schedular -> kis thread ko bhejna hai kisko nhi

Component in java which decides which thread to run or execute and which thread to wait is
Thread schedular in java ->

Factor of Thread schedular ->

Priority -> priority in thread - >1 - 10 , thread highest priority -> 10 and lowest toh hoga 1 or normal toh
hoga 5
Time of Arrival -> first come first serve Algorithm

Sleep() ->

Thread sleep meaning which thread to wait -> for a time -> interval ->

Joining thread
Thread pool
Garbage Collection
Call thread a twice()

Java 8 ->

Collection
File
JDBC connection
1 / 2 mini project with OOPS -> 2

You might also like