SlideShare une entreprise Scribd logo
1  sur  4
Télécharger pour lire hors ligne
Core Java

Debasish Pratihari

Thread


A thread is the basic unit to which the operating
system allocates processor time.



Threads are useful to execute more or less
independent code segments concurrently of a
program.



Is knows as light-weight process.



Threads are always owned and managed by
operating system.



Every program has at least one thread.

User Thread


A user thread has a life-time of its own.



It is not depended on the thread that creates it.



It can continue execution after the thread that
created has ended.

Daemon Thread


Is a background thread that sub-ordinate to the
thread that creates it



When the thread that created the daemon
thread ends, the daemon thread dies with it.



A thread can be set to daemon before it starts



Threads

created

from

daemon

thread

are

daemon by default.

Lecture/core/thread1/20

Page #1

feel the Technology…
Core Java

Debasish Pratihari

Process


It has its own address space.



A process can’t access another process’s
memory .



Each process provides the resources needed to
execute a program.



Threads belongs to same process shares same
address space.



A process has at least one thread of execution.

Thread Objects:


Each thread is associated with an instance of
the class Thread



There are two ways for using thread object
 Directly controlling thread
 Using executor

Creating Thread
 Provide a Runnable Object
class Lakshya implements Runnable{
--}


Sub class Thread
class Lakshya extends Thread{
--}

Lecture/core/thread1/20

Page #2

feel the Technology…
Core Java

Debasish Pratihari

Thread State:


New Born State: When we create a Thread
Object then a Thread is born.



Runnable State: When we call the start( )
method on a thread then thread is in the
Runnable state i.e., the threads in Runnable
state are all waiting in a queue for the
availability of CPU attention or their turns to
come.



Running State: When a thread got the time of
CPU then it starts execution for a particular
interval of time (time slice) this state is called as
Running state.



Blocked state: A thread is in the blocked state
when it is prevented to entered into Runnable
state.



Dead state: This is the end of life of a thread,
when a thread completes execution comes to
the dead state. Also we can dead state by
calling stop( ) method.

New
Born

Start ( )

sleep ( )

Runnable
State

Stop ( )
Scheduling

Dead
State

Lecture/core/thread1/20

Running
State

Block
State
after time-slice
or
yield( )

Page #3

feel the Technology…
Core Java


Debasish Pratihari

A Thread enters into blocked state under the
following situation.






By sleeping a thread.
If a thread is waiting for I/O operation.
If a thread is Interrupted.
If a thread is waiting for lock available.

Thread Life-Cycle
25%
New
Born
start( )

start ( )
notify( )/ notifyAll ( )

Runnable
State

wait lock available
I/O complete
after t time

Scheduling
mechanism

after time
slice
sleep( )
wait( )

Running
State

wait for Lock
wait for I/O
sleep( t )

B
L
O
C
K
E
D
S
T
A
T
E

Dead
State

Lecture/core/thread1/20

Page #4

feel the Technology…

Contenu connexe

Tendances

Java Multithreading
Java MultithreadingJava Multithreading
Java MultithreadingRajkattamuri
 
Thread presentation
Thread presentationThread presentation
Thread presentationAAshish Ojha
 
Life cycle-of-a-thread
Life cycle-of-a-threadLife cycle-of-a-thread
Life cycle-of-a-threadjavaicon
 
Intro To .Net Threads
Intro To .Net ThreadsIntro To .Net Threads
Intro To .Net Threadsrchakra
 
Multithreading
MultithreadingMultithreading
Multithreadingbackdoor
 
Multithread Programing in Java
Multithread Programing in JavaMultithread Programing in Java
Multithread Programing in JavaM. Raihan
 
Multithreading in-java
Multithreading in-javaMultithreading in-java
Multithreading in-javaaalipalh
 
Java Thread & Multithreading
Java Thread & MultithreadingJava Thread & Multithreading
Java Thread & Multithreadingjehan1987
 
Basic of Multithreading in JAva
Basic of Multithreading in JAvaBasic of Multithreading in JAva
Basic of Multithreading in JAvasuraj pandey
 
Developing Multithreaded Applications
Developing Multithreaded ApplicationsDeveloping Multithreaded Applications
Developing Multithreaded ApplicationsBharat17485
 
Multithreading In Java
Multithreading In JavaMultithreading In Java
Multithreading In Javaparag
 
Multithreading in java
Multithreading in javaMultithreading in java
Multithreading in javajunnubabu
 

Tendances (19)

Java Multithreading
Java MultithreadingJava Multithreading
Java Multithreading
 
Thread presentation
Thread presentationThread presentation
Thread presentation
 
Java Threads
Java ThreadsJava Threads
Java Threads
 
Life cycle-of-a-thread
Life cycle-of-a-threadLife cycle-of-a-thread
Life cycle-of-a-thread
 
Thread model in java
Thread model in javaThread model in java
Thread model in java
 
Threads concept in java
Threads concept in javaThreads concept in java
Threads concept in java
 
Intro To .Net Threads
Intro To .Net ThreadsIntro To .Net Threads
Intro To .Net Threads
 
Multithreading
MultithreadingMultithreading
Multithreading
 
Multithread Programing in Java
Multithread Programing in JavaMultithread Programing in Java
Multithread Programing in Java
 
Multithreading in-java
Multithreading in-javaMultithreading in-java
Multithreading in-java
 
Java Thread & Multithreading
Java Thread & MultithreadingJava Thread & Multithreading
Java Thread & Multithreading
 
Basic of Multithreading in JAva
Basic of Multithreading in JAvaBasic of Multithreading in JAva
Basic of Multithreading in JAva
 
Developing Multithreaded Applications
Developing Multithreaded ApplicationsDeveloping Multithreaded Applications
Developing Multithreaded Applications
 
Java threading
Java threadingJava threading
Java threading
 
Threads in Java
Threads in JavaThreads in Java
Threads in Java
 
Multithreading In Java
Multithreading In JavaMultithreading In Java
Multithreading In Java
 
Multithreading Concepts
Multithreading ConceptsMultithreading Concepts
Multithreading Concepts
 
Java thread
Java threadJava thread
Java thread
 
Multithreading in java
Multithreading in javaMultithreading in java
Multithreading in java
 

En vedette

Threads (operating System)
Threads (operating System)Threads (operating System)
Threads (operating System)Prakhar Maurya
 
Chapter 2: Operating System Structures
Chapter 2: Operating System StructuresChapter 2: Operating System Structures
Chapter 2: Operating System StructuresShafaan Khaliq Bhatti
 
Coral Exodo - 06.05.07
Coral Exodo - 06.05.07Coral Exodo - 06.05.07
Coral Exodo - 06.05.07Jubrac Jacui
 
Presentatie Starterslift Breda - Online marketing
Presentatie Starterslift Breda - Online marketingPresentatie Starterslift Breda - Online marketing
Presentatie Starterslift Breda - Online marketingSjef Kerkhofs
 
Codemotion twitter programming
Codemotion twitter programmingCodemotion twitter programming
Codemotion twitter programmingMatteo Baccan
 
JIPDay 2005: Xlet Java Programming
JIPDay 2005: Xlet Java ProgrammingJIPDay 2005: Xlet Java Programming
JIPDay 2005: Xlet Java ProgrammingMatteo Baccan
 
小企业金融业务品牌推广方案 Push(v4.0)
小企业金融业务品牌推广方案 Push(v4.0)小企业金融业务品牌推广方案 Push(v4.0)
小企业金融业务品牌推广方案 Push(v4.0)Push ,Beijing
 
Migration Intro
Migration IntroMigration Intro
Migration Introdazza50
 
Clive Shepherd at LP2010
Clive Shepherd at LP2010Clive Shepherd at LP2010
Clive Shepherd at LP2010Paul McElvaney
 
Joanne jacobs at LP2010
Joanne jacobs at LP2010Joanne jacobs at LP2010
Joanne jacobs at LP2010Paul McElvaney
 
Scenario exercise 2014 mid atlantic technical communication conference DDeBoard
Scenario exercise 2014 mid atlantic technical communication conference DDeBoardScenario exercise 2014 mid atlantic technical communication conference DDeBoard
Scenario exercise 2014 mid atlantic technical communication conference DDeBoardddeboard
 
Developing Policy for Emerging Technologies
Developing Policy for Emerging TechnologiesDeveloping Policy for Emerging Technologies
Developing Policy for Emerging TechnologiesLovisa Williams
 
Pattern Learning
Pattern LearningPattern Learning
Pattern Learningjbetter
 
維基經濟學
維基經濟學維基經濟學
維基經濟學sdfvb
 
Culto De Ferias - 26.07.07
Culto De Ferias - 26.07.07Culto De Ferias - 26.07.07
Culto De Ferias - 26.07.07Jubrac Jacui
 

En vedette (20)

Ch4 Threads
Ch4 ThreadsCh4 Threads
Ch4 Threads
 
Threads (operating System)
Threads (operating System)Threads (operating System)
Threads (operating System)
 
Chapter 2: Operating System Structures
Chapter 2: Operating System StructuresChapter 2: Operating System Structures
Chapter 2: Operating System Structures
 
Coral Exodo - 06.05.07
Coral Exodo - 06.05.07Coral Exodo - 06.05.07
Coral Exodo - 06.05.07
 
Presentatie Starterslift Breda - Online marketing
Presentatie Starterslift Breda - Online marketingPresentatie Starterslift Breda - Online marketing
Presentatie Starterslift Breda - Online marketing
 
Codemotion twitter programming
Codemotion twitter programmingCodemotion twitter programming
Codemotion twitter programming
 
JIPDay 2005: Xlet Java Programming
JIPDay 2005: Xlet Java ProgrammingJIPDay 2005: Xlet Java Programming
JIPDay 2005: Xlet Java Programming
 
小企业金融业务品牌推广方案 Push(v4.0)
小企业金融业务品牌推广方案 Push(v4.0)小企业金融业务品牌推广方案 Push(v4.0)
小企业金融业务品牌推广方案 Push(v4.0)
 
Lecture 18
Lecture 18Lecture 18
Lecture 18
 
Migration Intro
Migration IntroMigration Intro
Migration Intro
 
Clive Shepherd at LP2010
Clive Shepherd at LP2010Clive Shepherd at LP2010
Clive Shepherd at LP2010
 
Joanne jacobs at LP2010
Joanne jacobs at LP2010Joanne jacobs at LP2010
Joanne jacobs at LP2010
 
280 slides
280 slides280 slides
280 slides
 
Scenario exercise 2014 mid atlantic technical communication conference DDeBoard
Scenario exercise 2014 mid atlantic technical communication conference DDeBoardScenario exercise 2014 mid atlantic technical communication conference DDeBoard
Scenario exercise 2014 mid atlantic technical communication conference DDeBoard
 
Developing Policy for Emerging Technologies
Developing Policy for Emerging TechnologiesDeveloping Policy for Emerging Technologies
Developing Policy for Emerging Technologies
 
Pattern Learning
Pattern LearningPattern Learning
Pattern Learning
 
KDE: a solution for business environments
KDE: a solution for business environmentsKDE: a solution for business environments
KDE: a solution for business environments
 
維基經濟學
維基經濟學維基經濟學
維基經濟學
 
Mobile Tv
Mobile TvMobile Tv
Mobile Tv
 
Culto De Ferias - 26.07.07
Culto De Ferias - 26.07.07Culto De Ferias - 26.07.07
Culto De Ferias - 26.07.07
 

Similaire à Core Java Threads Explained

econtent thread in java.pptx
econtent thread in java.pptxecontent thread in java.pptx
econtent thread in java.pptxramyan49
 
Multithreading Introduction and Lifecyle of thread
Multithreading Introduction and Lifecyle of threadMultithreading Introduction and Lifecyle of thread
Multithreading Introduction and Lifecyle of threadKartik Dube
 
Multithreading
MultithreadingMultithreading
Multithreadingsagsharma
 
Multithreading in java
Multithreading in javaMultithreading in java
Multithreading in javaMonika Mishra
 
MULTI THREADING IN JAVA
MULTI THREADING IN JAVAMULTI THREADING IN JAVA
MULTI THREADING IN JAVAVINOTH R
 
Multithreading programming in java
Multithreading programming in javaMultithreading programming in java
Multithreading programming in javaElizabeth alexander
 
Multithreading in java
Multithreading in javaMultithreading in java
Multithreading in javaKavitha713564
 
Multithreading in java
Multithreading in javaMultithreading in java
Multithreading in javaKavitha713564
 
Multithreading
MultithreadingMultithreading
MultithreadingF K
 
Java multithreading
Java multithreadingJava multithreading
Java multithreadingMohammed625
 
Unit-3 MULTITHREADING-2.pdf
Unit-3 MULTITHREADING-2.pdfUnit-3 MULTITHREADING-2.pdf
Unit-3 MULTITHREADING-2.pdfGouthamSoma1
 

Similaire à Core Java Threads Explained (20)

Slide 7 Thread-1.pptx
Slide 7 Thread-1.pptxSlide 7 Thread-1.pptx
Slide 7 Thread-1.pptx
 
Threading concepts
Threading conceptsThreading concepts
Threading concepts
 
econtent thread in java.pptx
econtent thread in java.pptxecontent thread in java.pptx
econtent thread in java.pptx
 
Multithreading Introduction and Lifecyle of thread
Multithreading Introduction and Lifecyle of threadMultithreading Introduction and Lifecyle of thread
Multithreading Introduction and Lifecyle of thread
 
Multithreading in java
Multithreading in javaMultithreading in java
Multithreading in java
 
Java Threads
Java ThreadsJava Threads
Java Threads
 
Multithreading
MultithreadingMultithreading
Multithreading
 
Multithreading in java
Multithreading in javaMultithreading in java
Multithreading in java
 
Md09 multithreading
Md09 multithreadingMd09 multithreading
Md09 multithreading
 
MULTI THREADING IN JAVA
MULTI THREADING IN JAVAMULTI THREADING IN JAVA
MULTI THREADING IN JAVA
 
Multithreading programming in java
Multithreading programming in javaMultithreading programming in java
Multithreading programming in java
 
Java
JavaJava
Java
 
Multithreading in java
Multithreading in javaMultithreading in java
Multithreading in java
 
Multithreading in java
Multithreading in javaMultithreading in java
Multithreading in java
 
Multithreading
MultithreadingMultithreading
Multithreading
 
Java
JavaJava
Java
 
multithreading
multithreadingmultithreading
multithreading
 
Java multithreading
Java multithreadingJava multithreading
Java multithreading
 
Unit-3 MULTITHREADING-2.pdf
Unit-3 MULTITHREADING-2.pdfUnit-3 MULTITHREADING-2.pdf
Unit-3 MULTITHREADING-2.pdf
 
Java unit 12
Java unit 12Java unit 12
Java unit 12
 

Plus de Debasish Pratihari (19)

Lecture 24
Lecture 24Lecture 24
Lecture 24
 
Lecture 23
Lecture 23Lecture 23
Lecture 23
 
Lecture 22
Lecture 22Lecture 22
Lecture 22
 
Lecture 21
Lecture 21Lecture 21
Lecture 21
 
Lecture 19
Lecture 19Lecture 19
Lecture 19
 
Lecture 17
Lecture 17Lecture 17
Lecture 17
 
Lecture 16
Lecture 16Lecture 16
Lecture 16
 
Lecture 14
Lecture 14Lecture 14
Lecture 14
 
Lecture 10
Lecture 10Lecture 10
Lecture 10
 
Lecture 9
Lecture 9Lecture 9
Lecture 9
 
Lecture 8
Lecture 8Lecture 8
Lecture 8
 
Lecture 7
Lecture 7Lecture 7
Lecture 7
 
Lecture 6
Lecture 6Lecture 6
Lecture 6
 
Lecture 5
Lecture 5Lecture 5
Lecture 5
 
Lecture 4
Lecture 4Lecture 4
Lecture 4
 
Lecture 3
Lecture 3Lecture 3
Lecture 3
 
Lecture 2
Lecture 2Lecture 2
Lecture 2
 
Lecture 1
Lecture 1Lecture 1
Lecture 1
 
Lecture25
Lecture25Lecture25
Lecture25
 

Dernier

Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 

Dernier (20)

Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 

Core Java Threads Explained

  • 1. Core Java Debasish Pratihari Thread  A thread is the basic unit to which the operating system allocates processor time.  Threads are useful to execute more or less independent code segments concurrently of a program.  Is knows as light-weight process.  Threads are always owned and managed by operating system.  Every program has at least one thread. User Thread  A user thread has a life-time of its own.  It is not depended on the thread that creates it.  It can continue execution after the thread that created has ended. Daemon Thread  Is a background thread that sub-ordinate to the thread that creates it  When the thread that created the daemon thread ends, the daemon thread dies with it.  A thread can be set to daemon before it starts  Threads created from daemon thread are daemon by default. Lecture/core/thread1/20 Page #1 feel the Technology…
  • 2. Core Java Debasish Pratihari Process  It has its own address space.  A process can’t access another process’s memory .  Each process provides the resources needed to execute a program.  Threads belongs to same process shares same address space.  A process has at least one thread of execution. Thread Objects:  Each thread is associated with an instance of the class Thread  There are two ways for using thread object  Directly controlling thread  Using executor Creating Thread  Provide a Runnable Object class Lakshya implements Runnable{ --}  Sub class Thread class Lakshya extends Thread{ --} Lecture/core/thread1/20 Page #2 feel the Technology…
  • 3. Core Java Debasish Pratihari Thread State:  New Born State: When we create a Thread Object then a Thread is born.  Runnable State: When we call the start( ) method on a thread then thread is in the Runnable state i.e., the threads in Runnable state are all waiting in a queue for the availability of CPU attention or their turns to come.  Running State: When a thread got the time of CPU then it starts execution for a particular interval of time (time slice) this state is called as Running state.  Blocked state: A thread is in the blocked state when it is prevented to entered into Runnable state.  Dead state: This is the end of life of a thread, when a thread completes execution comes to the dead state. Also we can dead state by calling stop( ) method. New Born Start ( ) sleep ( ) Runnable State Stop ( ) Scheduling Dead State Lecture/core/thread1/20 Running State Block State after time-slice or yield( ) Page #3 feel the Technology…
  • 4. Core Java  Debasish Pratihari A Thread enters into blocked state under the following situation.     By sleeping a thread. If a thread is waiting for I/O operation. If a thread is Interrupted. If a thread is waiting for lock available. Thread Life-Cycle 25% New Born start( ) start ( ) notify( )/ notifyAll ( ) Runnable State wait lock available I/O complete after t time Scheduling mechanism after time slice sleep( ) wait( ) Running State wait for Lock wait for I/O sleep( t ) B L O C K E D S T A T E Dead State Lecture/core/thread1/20 Page #4 feel the Technology…