[concurrency-interest] Condition.awaitNanos
Peter Veentjer
alarmnummer at gmail.com
Fri Mar 10 03:28:48 EST 2006
I have a question about the Condition.awaitNanos function. The
documentation says that if a 0 or less is returned if a timeout has
occured.
"A value less than or equal to zero if the wait has timed out; "
It also says that a value less than the nanosTimeout is returned, when
it is signalled or interrupted:
"otherwise an estimate, that is strictly less than the nanosTimeout
argument, of the time still remaining when this method returned."
I have 3 questions:
-what happens if the Condition.awaitNanos is called with a value less
than or equal to zero? I guess that the function returns immediately
without any waiting.
-what happens if the Condition.awaitNanos is called with a value x,
and the the wait for signalling/interrupt also took time x. So the
remaining time is 0. 0 indicates that it received a timeout, but zero
also could be a signal to indicate that the call was succesfull.
-what happens if the Condition.awaitNanos is called with a value 1,
the wait took 0, so the remaining time is 1 (so it should be decreased
to zero so the value is less than the original timeout).
So I don`t have a clear understanding what happens with the
Condition.awaitNanos if the remaining timeout is around zero.
The reason I`m asking this is that I`m making a function that does the
same for locks:
long tryLockNanos(Lock lock, nanosTimeout){....}
And I don`t have a good understanding how I can deal with (almost)
zero timeouts.
More information about the Concurrency-interest
mailing list