[ nice-Bugs-1090881 ] IllegalMonitorStateException
"SourceForge.net" <[email protected]> Fri, 24 Dec 2004 08:11:56 -0800
| Newsgroups | gmane.comp.lang.nice.devel |
|---|---|
| Message-ID | <[email protected]> |
Bugs item #1090881, was opened at 2004-12-24 19:11
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=112788&aid=1090881&group_id=12788
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Artem Gr Kozarezov (artemgr)
Assigned to: Nobody/Anonymous (nobody)
Summary: IllegalMonitorStateException
Initial Comment:
The following program:
void main( String[] ){
List<Integer> list = new LinkedList();
int n = 9;
while( 0 != --n ) list.add( new Integer( n ) );
while( true ){
synchronized( list ){
if( list.isEmpty() ) break;
list.removeAt( 0 );
}
}
println( "OK" );
}
prints
OK
Exception in thread "main"
java.lang.IllegalMonitorStateException
at sync.fun.main(sync.nice:9)
at sync.dispatch.main(dispatch.nice)
It's strange also to see "OK". In real application the
thread of control was interrupted (jumped to the
appropriate catch block).
It is possible to workaround this bug, by moving
"break" outside of the "synchronized" block.
nicec --version
Nice compiler version 0.9.10 prerelease (build
2004.12.07, 13:42:26 UTC)
Compiled using JDK 1.4.2-01
java version "1.4.2_04"
Java(TM) 2 Runtime Environment, Standard Edition (build
1.4.2_04-b05)
Java HotSpot(TM) Client VM (build 1.4.2_04-b05, mixed mode)
The similar Java program (see below) works without
exceptions:
import java.util.*;
public class test {
public static void main( String[] argv ){
List list = new LinkedList();
int n = 9;
while( 0 != --n ) list.add( new Integer( n ) );
while( true ){
synchronized( list ){
if( list.isEmpty() ) break;
list.remove( 0 );
}
}
System.out.println( "OK" );
}
}
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=112788&aid=1090881&group_id=12788
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://productguide.itmanagersjournal.com/