Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 19 May 2010 20:24:32 +0200
From:      mocra Moc <mmmocra9@gmail.com>
To:        freebsd-java@freebsd.org
Subject:   diablo 1.6.0_07-b02, threads/interrupt
Message-ID:  <AANLkTilLuPS-zcCo1FJxHmKO34Eu6lw7zKgsL7JIx2FQ@mail.gmail.com>

next in thread | raw e-mail | index | archive | help
hello,
i think there is something like a bug in diablo-jdk 1.6.0_07-b02 with
threads/interrupt

following example should print something like

there is a life before death..
active...
active...
active...
active...
interrupt in sleep()
end

but unfortunately, the program stops within the catch-block

public class ThreadTest {
    public static void main(String[] args) {
        Thread t = new Thread() {
            public void run()
            {
                System.out.println( "there is a life before death.." );

                while (!isInterrupted() ) {
                    System.out.println( "active..."
);
                    try  {
                        Thread.sleep( 500 );
                        } catch ( InterruptedException e ) {
                            interrupt();
                            System.out.println( "interrupt in sleep()" );

                    }
                }
                System.out.println( "end" );
            }
        };
        t.start();
        try {
            Thread.sleep( 2000 );
        } catch (InterruptedException e) {}

        t.interrupt();
    }
}

but the output is:
there is a life before death..
active...
active...
active...
active...

so, IMO there is sum bug in interrupt()/isInterrupted(). within the
catch-block the interrupt-flag is set to false, so you have to set it
manually by interrupt(), but the program stops after interrupt() without
printing neither "interrupt in sleep" nor "end"

my system:
FreeBSD 8.0-RELEASE-p2 (i386)
java version "1.6.0_07"
Diablo Java(TM) SE Runtime Environment (build 1.6.0_07-b02)
Diablo Java HotSpot(TM) Server VM (build 10.0-b23, mixed mode)

also tried with another FreeBSD machine, with diablo-1.6.0_07-b02 too -
doesn't work

works fine on a fedora system with Java(TM) SE Runtime Environment (build
1.6.0_18-b07)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?AANLkTilLuPS-zcCo1FJxHmKO34Eu6lw7zKgsL7JIx2FQ>