• Post Reply Bookmark Topic Watch Topic
  • New Topic

SCJD Book Page 154

Keith Nagle
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • 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,
Gravity is a harsh mistress. But this tiny ad is pretty easy to deal with:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!