JDK-6809246 : EventDispatchThread shouldn't be reinitialized for disposed AppContexts
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 7
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2009-02-24
  • Updated: 2011-07-07
  • Resolved: 2011-07-07
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 b74Fixed
Related Reports
Relates :  
Description
This issue is reported at java.net forum:

http://forums.java.net/jive/thread.jspa?messageID=333410

Sometimes the following exception is observed in Java Console when applet is being destroyed:

java.lang.IllegalThreadStateException: forbid thread creation in disposed TG
	at sun.plugin.security.ActivatorSecurityManager.checkAccess(Unknown Source)
	at java.lang.ThreadGroup.checkAccess(Unknown Source)
	at java.lang.Thread.init(Unknown Source)
	at java.lang.Thread.<init>(Unknown Source)
	at java.awt.EventDispatchThread.<init>(Unknown Source)
	at java.awt.EventQueue$1.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.awt.EventQueue.initDispatchThread(Unknown Source)
	at java.awt.EventQueue.postEventPrivate(Unknown Source)
	at java.awt.EventQueue.postEvent(Unknown Source)
	at java.awt.EventQueue.invokeAndWait(Unknown Source)
	at sun.applet.AppletPanel.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)

It's clear that it's thrown when AWT tries to create a new EventDispatchThread instance for disposed AppContext.

Comments
SUGGESTED FIX Webrev for 6878284: http://sa.sfbay.sun.com/projects/awt_data/7/6878284/
17-05-2011

EVALUATION EventQueue.initDispatchThread() has already got a check for threadGroup.isDestroyed(), however it seems to be not enough. Instead, we should check for AppContext.isDisposed() as it's set to true before thread group disposal.
24-02-2009