public interface ActiveEvent
dispatch()
方法将被调用,当事件调度,使用
EventDispatchThread
。
这是避免死锁的一个非常有用的机制。如果一个线程在临界区中执行(即,它已经进入了一个或多个监视器),调用其他同步的代码可能会导致死锁。为了避免潜在的死锁,一个ActiveEvent
可以创建在以后运行代码的第二部分。如果监视器上有争用,第二个线程将被简单地阻塞,直到第一个线程完成它的工作并退出它的监视器。
为安全起见,通常需要使用一个ActiveEvent
避免关键线程调用不受信任的代码。例如,对等实现可以使用此设备避免从系统线程中调用用户代码。这样做可以避免潜在的死锁和拒绝服务攻击。
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.