java.lang.Object | |
↳ | sun.awt.AWTAutoShutdown |
This class is to let AWT shutdown automatically when a user is done with AWT. It tracks AWT state using the following parameters:
peerMap
- the map between the existing peer objects
and their associated targets
toolkitThreadBusy
- whether the toolkit thread
is waiting for a new native event to appear in its queue
or is dispatching an event
busyThreadSet
- a set of all the event dispatch
threads that are busy at this moment, i.e. those that are not
waiting for a new event to appear in their event queue.
AWT is considered to be in ready-to-shutdown state when
peerMap
is empty and toolkitThreadBusy
is false and busyThreadSet
is empty.
The internal AWTAutoShutdown logic secures that the single non-daemon
thread (blockerThread
) is running when AWT is not in
ready-to-shutdown state. This blocker thread is to prevent AWT from
exiting since the toolkit thread is now daemon and all the event
dispatch threads are started only when needed. Once it is detected
that AWT is in ready-to-shutdown state this blocker thread waits
for a certain timeout and if AWT state doesn't change during timeout
this blocker thread terminates all the event dispatch threads and
exits.
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Returns reference to a single AWTAutoShutdown instance.
| |||||||||||
Add a specified thread to the set of busy event dispatch threads.
| |||||||||||
Remove a specified thread from the set of busy event dispatch threads.
| |||||||||||
Notify that the toolkit thread is not waiting for a native event
to appear in its queue.
| |||||||||||
Notify that the toolkit thread is waiting for a native event
to appear in its queue.
| |||||||||||
Implementation of the Runnable interface.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
From interface
java.lang.Runnable
|
Returns reference to a single AWTAutoShutdown instance.
Add a specified thread to the set of busy event dispatch threads. If this set already contains the specified thread, the call leaves this set unchanged and returns silently.
thread | thread to be added to this set, if not present. |
---|
notifyThreadFree(Thread)
Remove a specified thread from the set of busy event dispatch threads. If this set doesn't contain the specified thread, the call leaves this set unchanged and returns silently.
thread | thread to be removed from this set, if present. |
---|
notifyThreadBusy(Thread)
Notify that the toolkit thread is not waiting for a native event to appear in its queue.
notifyToolkitThreadFree()
Notify that the toolkit thread is waiting for a native event to appear in its queue.
notifyToolkitThreadFree()
Implementation of the Runnable interface. Incapsulates the blocker thread functionality.