— Scott McNealy, Sun Microsystems Chairman, President and ceo



Download 40,57 Mb.
Pdf ko'rish
bet457/555
Sana26.05.2022
Hajmi40,57 Mb.
#609235
1   ...   453   454   455   456   457   458   459   460   ...   555
Bog'liq
Head First Java (Kathy Sierra, Bert Bates) (z-lib.org)

496
 
chapter 15
RUNNABLE
RUNNING
Selected to run
Typical runnable/running loop
Sent back to runnable 
so another thread can 
have a chance
Typically, a thread moves back and 
forth between runnable and running, 
as the JVM thread scheduler selects a 
thread to run and then kicks it back 
out so another thread gets a chance.
A thread can be made 
temporarily not-runnable
The thread scheduler can move a 
running thread into a blocked state, 
for a variety of reasons. For example, 
the thread might be executing code 
to read from a Socket input stream, 
but there isn’t any data to read. The 
scheduler will move the thread out 
of the running state until something 
becomes available. Or the executing 
code might have told the thread to 
put itself to sleep (sleep()). Or the 
thread might be waiting because it 
tried to call a method on an object
and that object was ‘locked’. In that 
case, the thread can’t continue until 
the object’s lock is freed by the thread 
that has it.
All of those conditions (and more) 
cause a thread to become temporarily 
not-runnable.
RUNNABLE
RUNNING
BLOCKED
Sent to a temporary 
non-runnable state 
until it can become 
runnable again.
sleeping, waiting for another thread to finish, 
waiting for data to be available on the stream, 
waiting for an object’s lock...
thread 
states


networking 
and
threads
you are here
4
497
The Thread Scheduler
Number four, you’ve had 
enough time. Back to runnable. 
Number two, looks like you’re up! 
Oh, now it looks like you’re gonna have 
to sleep. Number five, come take his 
place. Number two, you’re still 
sleeping...

Download 40,57 Mb.

Do'stlaringiz bilan baham:
1   ...   453   454   455   456   457   458   459   460   ...   555




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish