[concurrency-interest] interrupt / notify races even in 6.0 beta?

Dawid Kurzyniec dawidk at mathcs.emory.edu
Sun May 14 23:31:49 EDT 2006


The following code:

*public* *class* Test {
    *public* static void main(*String*[] args) *throws* *Exception* {
        final *Object* lock = *new* *Object*();
        *Thread* t = *new* *Thread*() {
            *public* void run() {
                *try* {
                    *synchronized* (lock) { lock.wait(); }
                    *System*.out.println("Awaken");
                } *catch* (*InterruptedException* e) {
                    *System*.out.println("Interrupted");
                }
            }
        };
        t.start();
        *Thread*.sleep(100);
        t.interrupt();
        *synchronized* (lock) { lock.notify(); }
        t.join();
    }
}


reports "Awaken" instead of "Interrupted" on all JVMs I tested it, 
including jdk6.0beta for Linux, as well as the latest 5.0 and 1.4.2 JVMs 
from SUN and IBM. I thought that the race between notify and interrupt 
has been long fixed?... This problem causes the backported ReentrantLock 
to miss the interruption and fail on 
ReentrantLockTest.testLockInterruptibly1(). What to think? And how come 
j.u.c.ReentrantLock is not affected?

Regards,
Dawid

-------------- next part --------------
An HTML attachment was scrubbed...
URL: /pipermail/attachments/20060514/d13f3824/attachment.html


More information about the Concurrency-interest mailing list