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