2695N/A * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 2695N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 2695N/A * This code is free software; you can redistribute it and/or modify it 2695N/A * under the terms of the GNU General Public License version 2 only, as 2695N/A * published by the Free Software Foundation. Oracle designates this 2695N/A * particular file as subject to the "Classpath" exception as provided 2695N/A * by Oracle in the LICENSE file that accompanied this code. 2695N/A * This code is distributed in the hope that it will be useful, but WITHOUT 2695N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 2695N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 2695N/A * version 2 for more details (a copy is included in the LICENSE file that 2695N/A * You should have received a copy of the GNU General Public License version 2695N/A * 2 along with this work; if not, write to the Free Software Foundation, 2695N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2695N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2695N/A * or visit www.oracle.com if you need additional information or have any 2695N/A * This utility class is used to suspend execution on a thread 2695N/A * while still allowing {@code EventDispatchThread} to dispatch events. 2695N/A * The API methods of the class are thread-safe. 2695N/A * @author Anton Tarasov, Artem Ananiev 2695N/A // Use a shared daemon timer to serve all the WaitDispatchSupports 2695N/A // When this WDS expires, we cancel the timer task leaving the 2695N/A // shared timer up and running 2695N/A * Creates a {@code WaitDispatchSupport} instance to 2695N/A * serve the given event dispatch thread. 2695N/A * @param dispatchThread An event dispatch thread that 2695N/A * should not stop dispatching events while waiting 2695N/A * Creates a {@code WaitDispatchSupport} instance to 2695N/A * serve the given event dispatch thread. 2695N/A * @param dispatchThread An event dispatch thread that 2695N/A * should not stop dispatching events while waiting 2695N/A * @param extCondition A conditional object used to determine 2695N/A * if the loop should be terminated 2695N/A * Creates a {@code WaitDispatchSupport} instance to 2695N/A * serve the given event dispatch thread. 2695N/A * The {@link EventFilter} is set on the {@code dispatchThread} 2695N/A * while waiting. The filter is removed on completion of the 2695N/A * @param dispatchThread An event dispatch thread that 2695N/A * should not stop dispatching events while waiting 2695N/A * @param filter {@code EventFilter} to be set 2695N/A * @param interval A time interval to wait for. Note that 2695N/A * when the waiting process takes place on EDT 2695N/A * there is no guarantee to stop it in the given time 2695N/A // We have two mechanisms for blocking: if we're on the 2695N/A // dispatch thread, start a new event pump; if we're 2695N/A // on any other thread, call wait() on the treelock 2695N/A // Dispose SequencedEvent we are dispatching on the the current 2695N/A // AppContext, to prevent us from hang - see 4531693 for details 2695N/A // In case the exit() method is called before starting 2695N/A // new event pump it will post the waking event to EDT. 2695N/A // The event will be handled after the the new event pump 2695N/A // starts. Thus, the enter() method will not hang. 2695N/A // Event pump should be privileged. See 6300270. 2695N/A // If the waiting process has been stopped because of the 2695N/A // time interval passed or an exception occurred, the state