— Scott McNealy, Sun Microsystems Chairman, President and ceo



Download 40,57 Mb.
Pdf ko'rish
bet451/555
Sana26.05.2022
Hajmi40,57 Mb.
#609235
1   ...   447   448   449   450   451   452   453   454   ...   555
Bog'liq
Head First Java (Kathy Sierra, Bert Bates) (z-lib.org)

Thread_t_=_new_Thread();_t.start();'>Thread t = new Thread();
t.start();
That’s it. By creating a new Thread object
you’ve launched a separate thread of 
execution, with its very own call stack.
Except for one problem.
That thread doesn’t actually do anything, 
so the thread “dies” virtually the instant 
it’s born. When a thread dies, its new 
stack disappears again. End of story.
So we’re missing one key component—
the thread’s job. In other words, we need 
the code that you want to have run by a 
separate thread.
Multiple threading in Java means we 
have to look at both the 
thread and the job 
that’s run by the thread. And we’ll also 
have to look at the Thread class in the 
java.lang package. (Remember, java.lang 
is the package you get imported for 
free, implicitly, and it’s where the classes 
most fundamental to the language live
including String and System.)


490
 
chapter 15
Java has multiple threads but only 
one Thread class
We can talk about thread with a lower-case ‘t’ and Thread 
with a capital ‘T’. When you see thread, we’re talking 
about a separate thread of execution. In other words, 
a separate call stack. When you see Thread, think of 
the Java naming convention. What, in Java, starts with a 
capital letter? Classes and interfaces. In this case, Thread 
is a class in the java.lang package. A Thread object 
represents a thread of execution; you’ll create an instance of 
class Thread each time you want to start up a new thread 
of execution.
thread
run( )
doStuff( )
go( )

Download 40,57 Mb.

Do'stlaringiz bilan baham:
1   ...   447   448   449   450   451   452   453   454   ...   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