J2SE Version (please include all output from java -version flag):
6u22
Does this problem occur on J2SE 5.0.x or 6ux ?
Yes, 1.6.0_07 - 1.6.0_22
Operating System Configuration Information:
Ubuntu, Vista, Windows 7
Bug Description:
On reloading applets, iLLegalMonitorStateException throws. The problem occur only
sporadic.
The exception seems occur on the new instance of the applet because do
see log output from
the new instance. The thread "Image Loader" is one of
customer's threads but the stacktrace show only Java code.
Exception in thread "Image Loader" java.lang.IllegalMonitorStateException
at java.util.concurrent.locks.ReentrantLock$Sync.tryRelease(ReentrantLock.java:127)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.release(AbstractQueuedSynchronizer.java:1175)
at java.util.concurrent.locks.ReentrantLock.unlock(ReentrantLock.java:431)
at java.util.concurrent.LinkedBlockingQueue.poll(LinkedBlockingQueue.java:402)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:944)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:906)
at java.lang.Thread.run(Thread.java:619)
the problem might be related to a static thread pool.
private final static ThreadPoolExecutor THREAD_POOL = new ThreadPoolExecutor(10,10, 5, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(), new ThreadFactory(){
public Thread newThread( Runnable run ) {
Thread thread = new Thread(run,"Image Loader");
thread.setDaemon( true );
thread.setPriority( Thread.NORM_PRIORITY );
return thread;
}
});
Unclear what Java do on a reload with this pool and its threads. But the bug
seems in ReentrantLock$Sync.tryRelease.
Aftre review it this method seems not
thread safe. Isn't the member exclusiveOwnerThread must be volatile.
Else an IllegalMonitorStateException can occur sporadic if 2 different thread
use the same lock in a short time.