1 /* 2 * @(#)ActiveEvent.java 1.13 03/12/19 3 * 4 * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 5 * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 6 */ 7 8 package java.awt; 9 10 /** 11 * An interface for events that know how to dispatch themselves. 12 * By implementing this interface an event can be placed upon the event 13 * queue and its <code>dispatch()</code> method will be called when the event 14 * is dispatched, using the <code>EventDispatchThread</code>. 15 * <p> 16 * This is a very useful mechanism for avoiding deadlocks. If 17 * a thread is executing in a critical section (i.e., it has entered 18 * one or more monitors), calling other synchronized code may 19 * cause deadlocks. To avoid the potential deadlocks, an 20 * <code>ActiveEvent</code> can be created to run the second section of 21 * code at later time. If there is contention on the monitor, 22 * the second thread will simply block until the first thread 23 * has finished its work and exited its monitors. 24 * <p> 25 * For security reasons, it is often desirable to use an <code>ActiveEvent</code> 26 * to avoid calling untrusted code from a critical thread. For 27 * instance, peer implementations can use this facility to avoid 28 * making calls into user code from a system thread. Doing so avoids 29 * potential deadlocks and denial-of-service attacks. 30 * 31 * @author Timothy Prinzing 32 * @version 1.13 12/19/03 33 * @since 1.2 34 */ 35 public interface ActiveEvent { 36 37 /** 38 * Dispatch the event to its target, listeners of the events source, 39 * or do whatever it is this event is supposed to do. 40 */ 41 public void dispatch(); 42 } 43