This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug java/12647] New: wait() bug on Win32
- From: "mkaufmann at student dot ethz dot ch" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 16 Oct 2003 18:17:53 -0000
- Subject: [Bug java/12647] New: wait() bug on Win32
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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();
}
}