JDK-7008079 : IllegalMonitorStateException on reloading Applet
  • Type: Bug
  • Component: deploy
  • Sub-Component: plugin
  • Affected Version: 6u22
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: x86
  • Submitted: 2010-12-20
  • Updated: 2011-03-02
  • Resolved: 2011-03-02
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7
7-poolResolved
Related Reports
Duplicate :  
Description
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.