[Bug java/12647] New: wait() bug on Win32
mkaufmann at student dot ethz dot ch
gcc-bugzilla@gcc.gnu.org
Thu Oct 16 18:17:00 GMT 2003
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12647
Summary: wait() bug on Win32
Product: gcc
Version: 3.3.1
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: java
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: mkaufmann at student dot ethz dot ch
CC: gcc-bugs at gcc dot gnu dot org
On Windows (I used the MinGW version 3.3.1 of gcj), there's a bug if a
synchronized method calls wait(). If the method containing wait() was invoked by
another synchronized method of the same object, then the calling thread keeps
the lock on this object.
Example program:
If you run this with the Java 1.4.1 VM on Windows, the output is
a
c
c
c
...
If compiled with GCJ on Windows, the output is only
a
Code of the example program:
public class Test
{
public static void main(String args[])
{
Test test = new Test();
new MyThread(test).start();
while(true)
{
try
{
Thread.sleep(1000);
}
catch (Exception e)
{
e.printStackTrace();
}
test.c();
}
}
public synchronized void a()
{
System.out.println("a");
b();
}
public synchronized void b()
{
try
{
wait();
}
catch (Exception e)
{
e.printStackTrace();
}
System.out.println("b");
}
public synchronized void c()
{
System.out.println("c");
}
}
class MyThread extends Thread
{
private Test test;
public MyThread(Test test)
{
this.test = test;
}
public void run()
{
test.a();
}
}
More information about the Gcc-bugs
mailing list