Arne Vajhøj wrote:
> puzzlecracker wrote:
>> It is a copy and paste from Doug Lea's Mutex implementation. I dont
>> understand the point of this line:
>> if (Thread.interrupted()) throw new InterruptedException();
>
> If interrupt has been called on the thread, then you do not
> want to start waiting !?!?
Is that simply a performance optimization? If not, it looks like
there's a race condition, because the thread can get interrupted
after that 'if'-statement completes but before entering the
'synchronized' block.
Or to put it a different way, if the thread is interrupted, this
code doesn't seem to guarantee that you won't start waiting.
- Logan


|