— Scott McNealy, Sun Microsystems Chairman, President and ceo



Download 40,57 Mb.
Pdf ko'rish
bet470/555
Sana26.05.2022
Hajmi40,57 Mb.
#609235
1   ...   466   467   468   469   470   471   472   473   ...   555
Bog'liq
Head First Java (Kathy Sierra, Bert Bates) (z-lib.org)

Monica’s check of the account was 
not valid, because Ryan had already 
checked and was still in the middle of 
making a withdrawal.
Monica must be stopped from getting 
into the account until Ryan wakes up and 
finishes his transaction. And vice-versa.
How did this 
happen?
Ryan and Monica 
output


networking 
and
threads
you are here
4
509
The lock works like this:
They need a lock for account access!
1
There’s a lock associated with the bank 
account transaction (checking the balance 
and withdrawing money). There’s only 
one key, and it stays with the lock until 
somebody wants to access the account.
2
When Ryan wants to access the bank 
account (to check the balance and withdraw 
money), he locks the lock and puts the key 
in his pocket. Now nobody else can access 
the account, since the key is gone.
3
Ryan keeps the key in his pocket until he 
finishes the transaction. He has the only 
key, so Monica can’t access the account 
(or the checkbook) until Ryan unlocks the 
account and returns the key. 
Now, even if Ryan falls asleep after he 
checks the balance, he has a guarantee 
that the balance will be the same when he 
wakes up, because he kept the key while he 
was asleep!
The bank account 
transaction is 
unlocked when 
nobody is using 
the account.
When Ryan 
wants to access 
the account, he 
secures the lock 
and takes the key. 
When Ryan is 
finished, he 
unlocks the lock 
and returns the 
key. Now the key 
is available for 
Monica (or Ryan 
again) to access 
the account.



Download 40,57 Mb.

Do'stlaringiz bilan baham:
1   ...   466   467   468   469   470   471   472   473   ...   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