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

Dawid Kurzyniec dawidk at mathcs.emory.edu
Tue May 16 00:17:28 EDT 2006


Doug Lea wrote:
> Dawid Kurzyniec wrote:
>>
>>
>> reports "Awaken" instead of "Interrupted" on all JVMs I tested it, 
>
> Are you sure?? It reports "interrupted" on all that I've tried it
> on, including 5.0 and mustang on both linux and solaris, and IBM 5.0
> on linux.

OK, so here's what I got after running a revised test program below on 
the machines I have access to:

*public* *class* Test *extends* *Thread* {

    final static *Object* lock = *new* *Object*();

    *public* void run() {
        *try* {
            *synchronized* (lock) { lock.wait(); }
            *System*.out.println("Awaken");
        } *catch* (*InterruptedException* e) {
            *System*.out.println("Interrupted");
        }
    }

    *public* static void main(*String*[] args) *throws* *Exception* {
        *Thread* t;
        t = *new* Test();
        t.start();
        *Thread*.sleep(100);
        t.interrupt();
        *synchronized* (lock) { lock.notify(); }
        t.join();
        t = *new* Test();
        t.start();
        *Thread*.sleep(100);
        *synchronized* (lock) { lock.notify(); }
        t.interrupt();
        t.join();
        *System*.out.println("Should be: first Interrupted; then Awaken");
        *System*.out.flush();
    }
}


Linux, 2 different machines but both with Mandriva 2006 and kernel 
2.6.12-12mdk-i686-up-4GB:

IBM 1.4.2, build cxia32142ifx-20060209 (SR4-1): Interrupted, Interrupted
IBM 1.5.0, build 2.3 x86-32 j9vmxi3223ifx-20060124: Awaken, Awaken

SUN: 1.4.1, 1.4.1_01, 1.4.2, 1.4.2_03, 1.4.2_06, 1.4.2_08, 1.5.0-beta, 
1.5.0-beta2, 1.5.0, 1.5.0_06, 1.6.0-beta (b59g): all Awaken, Awaken!


Solaris SPARC, SunOS 5.10 Generic_118822-25 sun4u:

SUN 1.3.1_02, 1.4.0_01, 1.4.1_01, 1.4.2_02, 1.4.2_06: Awaken, Awaken
SUN 1.5.0: Interrupted, Awaken (correct)
SUN 1.2.1_03: Interrupted, Interrupted (ocassionally the 2nd one is Awaken)

Windows XP SP2:

1.4.2_05, 1.5.0_06: Interrupted, Awaken (correct)


I suspect that on IBM SP2, I'd probably see Interrupted, Interrupted - 
judging from past backport bug reports.

It seems that this race is more pervasive that I thought. (I had the 
impression that it has been fixed somewhere in the 1.4 line). It means 
that the backport must bite the bullet. I am probably going to relax the 
unit test a little bit (by inserting a short sleep between interrupt() 
and notify()) to make it pass. (For anxious backport users: I wouldn't 
worry too much about it; the revised unit test is arguably unfairly 
pessimistic from the usage patterns point of view, and the code that now 
started failing the test is exactly the same as the one that we all 
happily used since dl.util.concurrent).

The continuous presence of this race in 1.5 and Mustang on Linux is the 
troubling, though. Since Doug says it's working for him, I am guessing 
that the problem may have something to do with the kernel version?... It 
would be good if somebody tested it on some other Linux boxes.

Regards,
Dawid

-------------- next part --------------
An HTML attachment was scrubbed...
URL: /pipermail/attachments/20060516/c6a9150f/attachment.html


More information about the Concurrency-interest mailing list