Posted By:
zohar_melamed
Posted On:
Friday, May 25, 2001 04:47 AM
Hi This question concerns the : public final void wait(long timeout) form of wait. Is it not odd that it returns void , and gives no indication of whether it timed out , or the object was signaled ... Trying to implement a Semaphore I was thinking this : (some details ommited) public synchronized boolean acquire(long waitFor) { if(count == 0){ if(wait(waitFor) == timedOut){ retrun false; }else{ count--; return true; } } However since wait(timeout) is void There i
More>>
Hi
This question concerns the :
public final void wait(long timeout)
form of wait.
Is it not odd that it returns void , and gives no indication of whether it
timed out
, or
the object was signaled ...
Trying to implement a Semaphore I was thinking this : (some details ommited)
public synchronized boolean acquire(long waitFor)
{
if(count == 0){
if(wait(waitFor) == timedOut){
retrun false;
}else{
count--;
return true;
}
}
However since
wait(timeout)
is
void
There is no way to find out if it timed out ...
I have solved this particular case , but was wondering about this problem in
general
Cheers
Zohar
<<Less