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