File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes SCJD Book Page 154 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "SCJD Book Page 154" Watch "SCJD Book Page 154" New topic

SCJD Book Page 154

Keith Nagle
Ranch Hand

Joined: May 06, 2008
Posts: 65
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,

SCJP 5.0
I agree. Here's the link:
subject: SCJD Book Page 154
It's not a secret anymore!