SlideShare ist ein Scribd-Unternehmen logo
1 von 4
Downloaden Sie, um offline zu lesen
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…

Weitere ähnliche Inhalte

Was ist angesagt?

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
 

Was ist angesagt? (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
 

Andere mochten auch

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
 

Andere mochten auch (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
 

Ähnlich wie 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
 

Ähnlich wie 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
 

Mehr von 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
 

Kürzlich hochgeladen

Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 

Kürzlich hochgeladen (20)

Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 

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…