Detecting a timeout at the Object.wait(int) method

I am trying to code a simple semaphore class, but keep getting into

problems.

The first question is, is there a way of, after the execution of the

wait(int) method, determining if it ended because of a notify() or

because of a timeout?

I want my semaphore to return any of 3 possible codes: signalled, timed

out, interrupted. I don't think there is a way to detect the timeout at

that level so I should use a workaround like some control variable, but

checking the counter is not good enough.

Any suggestion? I think there is no other option than keeping a thread

table...

(detecting the timeout is not only for informational purposes: if a

sem.waitOn() ends with a timeout, the counter should be restored, or I

keep getting useless waits later on).

And more generic, do you have the source code of a semaphore class that

provides the same behaviour as the old OS/2 semaphore system calls?

Thanks in advance...

Luis.

[1040 byte] By [lcrespo] at [2007-9-26 3:57:34]
# 1
I have found the following package EXTREMELY useful. You may want to have a look. http://gee.cs.oswego.edu/dl/
jeffmathis at 2007-6-29 12:49:32 > top of Java-index,Java HotSpot Virtual Machine,Specifications...