APIdia Launch Partner
Top Description Fields Constructors Methods
java.awt

pack-priv Class WaitDispatchSupport

extends Object
implements SecondaryLoop
Class Inheritance
All Implemented Interfaces
java.awt.SecondaryLoop
Imports
java.util.Timer, .TimerTask, java.util.concurrent.atomic.AtomicBoolean, sun.awt.PeerEvent, sun.util.logging.PlatformLogger

This utility class is used to suspend execution on a thread while still allowing EventDispatchThread to dispatch events. The API methods of the class are thread-safe.
Author
Anton Tarasov, Artem Ananiev
Since
1.7

Field Summary

Modifier and TypeField and Description
private AtomicBoolean
private volatile Conditional
private EventDispatchThread
private volatile Conditional
private EventFilter
private long
private AtomicBoolean
private AtomicBoolean
private static final PlatformLogger
private static Timer
private TimerTask
private final Runnable

Constructor Summary

AccessConstructor and Description
public
WaitDispatchSupport(EventDispatchThread
An event dispatch thread that should not stop dispatching events while waiting
dispatchThread
)

Creates a WaitDispatchSupport instance to serve the given event dispatch thread.

public
WaitDispatchSupport(EventDispatchThread
An event dispatch thread that should not stop dispatching events while waiting
dispatchThread
,
Conditional
A conditional object used to determine if the loop should be terminated
extCond
)

Creates a WaitDispatchSupport instance to serve the given event dispatch thread.

public
WaitDispatchSupport(EventDispatchThread
An event dispatch thread that should not stop dispatching events while waiting
dispatchThread
,
Conditional extCondition, EventFilter
EventFilter to be set
filter
,
long
A time interval to wait for. Note that when the waiting process takes place on EDT there is no guarantee to stop it in the given time
interval
)

Creates a WaitDispatchSupport instance to serve the given event dispatch thread.

Method Summary

Modifier and TypeMethod and Description
public boolean
enter()

Implements java.awt.SecondaryLoop.enter.

Blocks the execution of the current thread and enters a new secondary event loop on the event dispatch thread.

public boolean
exit()

Implements java.awt.SecondaryLoop.exit.

Unblocks the execution of the thread blocked by the enter method and exits the secondary loop.

private static final Object
private static synchronized void
private void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

afterExitback to summary
private AtomicBoolean afterExit
conditionback to summary
private volatile Conditional condition
dispatchThreadback to summary
private EventDispatchThread dispatchThread
extConditionback to summary
private volatile Conditional extCondition
filterback to summary
private EventFilter filter
intervalback to summary
private long interval
keepBlockingCTback to summary
private AtomicBoolean keepBlockingCT
keepBlockingEDTback to summary
private AtomicBoolean keepBlockingEDT
logback to summary
private static final PlatformLogger log
timerback to summary
private static Timer timer
timerTaskback to summary
private TimerTask timerTask
wakingRunnableback to summary
private final Runnable wakingRunnable

Constructor Detail

WaitDispatchSupportback to summary
public WaitDispatchSupport(EventDispatchThread dispatchThread)

Creates a WaitDispatchSupport instance to serve the given event dispatch thread.

Parameters
dispatchThread:EventDispatchThread

An event dispatch thread that should not stop dispatching events while waiting

Since
1.7
WaitDispatchSupportback to summary
public WaitDispatchSupport(EventDispatchThread dispatchThread, Conditional extCond)

Creates a WaitDispatchSupport instance to serve the given event dispatch thread.

Parameters
dispatchThread:EventDispatchThread

An event dispatch thread that should not stop dispatching events while waiting

extCond:Conditional

A conditional object used to determine if the loop should be terminated

Since
1.7
WaitDispatchSupportback to summary
public WaitDispatchSupport(EventDispatchThread dispatchThread, Conditional extCondition, EventFilter filter, long interval)

Creates a WaitDispatchSupport instance to serve the given event dispatch thread.

The EventFilter is set on the dispatchThread while waiting. The filter is removed on completion of the waiting process.

Parameters
dispatchThread:EventDispatchThread

An event dispatch thread that should not stop dispatching events while waiting

filter:EventFilter

EventFilter to be set

interval:long

A time interval to wait for. Note that when the waiting process takes place on EDT there is no guarantee to stop it in the given time

Since
1.7

Method Detail

enterback to summary
public boolean enter()

Implements java.awt.SecondaryLoop.enter.

Doc from java.awt.SecondaryLoop.enter.

Blocks the execution of the current thread and enters a new secondary event loop on the event dispatch thread.

This method can be called by any thread including the event dispatch thread. This thread will be blocked until the exit method is called or the loop is terminated. A new secondary loop will be created on the event dispatch thread for dispatching events in either case.

This method can only start one new event loop at a time per object. If a secondary event loop has already been started by this object and is currently still running, this method returns false to indicate that it was not successful in starting a new event loop. Otherwise, this method blocks the calling thread and later returns true when the new event loop is terminated. At such time, this object can again be used to start another new event loop.

Annotations
@Override
exitback to summary
public boolean exit()

Implements java.awt.SecondaryLoop.exit.

Doc from java.awt.SecondaryLoop.exit.

Unblocks the execution of the thread blocked by the enter method and exits the secondary loop.

This method resumes the thread that called the enter method and exits the secondary loop that was created when the enter method was invoked.

Note that if any other secondary loop is started while this loop is running, the blocked thread will not resume execution until the nested loop is terminated.

If this secondary loop has not been started with the enter method, or this secondary loop has already finished with the exit method, this method returns false, otherwise true is returned.

getTreeLockback to summary
private static final Object getTreeLock()
initializeTimerback to summary
private static synchronized void initializeTimer()
wakeupEDTback to summary
private void wakeupEDT()