• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

SCJD Book Page 154

 
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys, quick question about the reserveDVD and releaseDVD methods on pages 154 & 155 of the
SCJD book (Monkhouse & Camerlengo).

Can someone please explain the reserveDVD and releaseDVD methods to me in Layman's terms?

I've tried to get my head around these 2 methods but can't seem to.

Mainly the questions I have about the reserveDVD method are

If a thread acquires the lock, what is the point in it having to invoke



If a thread get's the lock, will this "if" statement wait immediately return true? Or, will 5 seconds always and then true will be returned.

Also, above all, if a thread can't obtain the lock by calling "lock.lock()" and blocks, how does the "if(!lockReleased.await(timeLeftMSec, TimeUnit....)" statement help us?
The reason I ask, is that if the lock is released and our blocking thread picks up the lock and enters the running state, the "if(!lockReleased.await(...))" will never
return false.

Any help greatly received,
Regards
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic