— Scott McNealy, Sun Microsystems Chairman, President and ceo



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

main()
myThread.start()
1
1
2
2
new thread
brainbarbell
Brain Barbell
What do you think the output will be if you run the 
ThreadTester class? (we’ll find out in a few pages)
Runnable 
interface


networking 
and
threads
you are here
4
495
The three states of a new thread
A Thread instance has been 
created but not started. 
In other words, there is a 
Thread 
object, but no thread 
of execution.
NEW
RUNNABLE
T
hread t = new Thread(r);
When you start the thread, it 
moves into the runnable state. 
This means the thread is ready 
to run and just waiting for its 
Big Chance to be selected for 
execution. At this point, there is 
a new call stack for this thread.
t.start();
RUNNING
t.start();
Selected to run
This is the state all threads lust 
after! To be The Chosen One. 
The Currently Running Thread. 
Only the JVM thread scheduler 
can make that decision. You 
can sometimes 
influence that 
decision, but you cannot force a 
thread to move from runnable 
to running. In the running 
state, a thread (and ONLY this 
thread) has an active call stack, 
and the method on the top of 
the stack is executing.
Thread t = new Thread(r);
this is where a thread 
wants to be! 
But there’s more. Once the thread becomes 
runnable, it can move back and forth between 
runnable, running, and an additional state: 
temporarily not runnable (also known as ‘blocked’).
“I’m good to go!”
“Can I 
supersize 
that for 
you?”
“I’m waiting to 
get started.”



Download 40,57 Mb.

Do'stlaringiz bilan baham:
1   ...   452   453   454   455   456   457   458   459   ...   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