Path: blob/master/src/java.desktop/share/classes/java/awt/ActiveEvent.java
41152 views
/*1* Copyright (c) 1997, 2002, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package java.awt;2627/**28* An interface for events that know how to dispatch themselves.29* By implementing this interface an event can be placed upon the event30* queue and its {@code dispatch()} method will be called when the event31* is dispatched, using the {@code EventDispatchThread}.32* <p>33* This is a very useful mechanism for avoiding deadlocks. If34* a thread is executing in a critical section (i.e., it has entered35* one or more monitors), calling other synchronized code may36* cause deadlocks. To avoid the potential deadlocks, an37* {@code ActiveEvent} can be created to run the second section of38* code at later time. If there is contention on the monitor,39* the second thread will simply block until the first thread40* has finished its work and exited its monitors.41* <p>42* For security reasons, it is often desirable to use an {@code ActiveEvent}43* to avoid calling untrusted code from a critical thread. For44* instance, peer implementations can use this facility to avoid45* making calls into user code from a system thread. Doing so avoids46* potential deadlocks and denial-of-service attacks.47*48* @author Timothy Prinzing49* @since 1.250*/51public interface ActiveEvent {5253/**54* Dispatch the event to its target, listeners of the events source,55* or do whatever it is this event is supposed to do.56*/57public void dispatch();58}596061