public interface ActiveEvent
An interface for events that know how to dispatch themselves. By implementing this interface an event can be placed upon the event queue and its dispatch() method will be called when the event is dispatched, using the EventDispatchThread.
This is a very useful mechanism for avoiding deadlocks. If a thread is executing in a critical section (i.e., it has entered one or more monitors), calling other synchronized code may cause deadlocks. To avoid the potential deadlocks, an ActiveEvent can be created to run the second section of code at later time. If there is contention on the monitor, the second thread will simply block until the first thread has finished its work and exited its monitors.
For security reasons, it is often desirable to use an ActiveEvent to avoid calling untrusted code from a critical thread. For instance, peer implementations can use this facility to avoid making calls into user code from a system thread. Doing so avoids potential deadlocks and denial-of-service attacks.
公共接口活动事件
一个知道如何调度自己的事件的接口。通过实现这个接口,事件可以放置在事件队列上,并且使用EdvestRebug线程在事件被调度时调用它的分派()方法。
这是避免死锁的一种非常有用的机制。如果线程在关键部分中执行(即,它已经进入一个或多个监视器),调用其他同步代码可能会导致死锁。为了避免潜在的死锁,可以创建AcvEvEnter以在稍后的时间运行代码的第二部分。如果在监视器上存在争用,则第二线程将简单地阻塞直到第一线程完成其工作并退出其监视器。
出于安全原因,经常需要使用AccVIEVE来避免从关键线程调用不受信任的代码。例如,对等实现可以使用此设施避免从系统线程调用用户代码。这样做避免了潜在的死锁和拒绝服务攻击。