01 /*
02 * Copyright 1997-2002 Sun Microsystems, Inc. All Rights Reserved.
03 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
04 *
05 * This code is free software; you can redistribute it and/or modify it
06 * under the terms of the GNU General Public License version 2 only, as
07 * published by the Free Software Foundation. Sun designates this
08 * particular file as subject to the "Classpath" exception as provided
09 * by Sun in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22 * CA 95054 USA or visit www.sun.com if you need additional information or
23 * have any questions.
24 */
25
26 package java.awt;
27
28 /**
29 * An interface for events that know how to dispatch themselves.
30 * By implementing this interface an event can be placed upon the event
31 * queue and its <code>dispatch()</code> method will be called when the event
32 * is dispatched, using the <code>EventDispatchThread</code>.
33 * <p>
34 * This is a very useful mechanism for avoiding deadlocks. If
35 * a thread is executing in a critical section (i.e., it has entered
36 * one or more monitors), calling other synchronized code may
37 * cause deadlocks. To avoid the potential deadlocks, an
38 * <code>ActiveEvent</code> can be created to run the second section of
39 * code at later time. If there is contention on the monitor,
40 * the second thread will simply block until the first thread
41 * has finished its work and exited its monitors.
42 * <p>
43 * For security reasons, it is often desirable to use an <code>ActiveEvent</code>
44 * to avoid calling untrusted code from a critical thread. For
45 * instance, peer implementations can use this facility to avoid
46 * making calls into user code from a system thread. Doing so avoids
47 * potential deadlocks and denial-of-service attacks.
48 *
49 * @author Timothy Prinzing
50 * @version 1.20 05/05/07
51 * @since 1.2
52 */
53 public interface ActiveEvent {
54
55 /**
56 * Dispatch the event to its target, listeners of the events source,
57 * or do whatever it is this event is supposed to do.
58 */
59 public void dispatch();
60 }
|