--- old/src/share/classes/java/awt/event/InvocationEvent.java 2012-07-10 13:41:55.000000000 +0400
+++ new/src/share/classes/java/awt/event/InvocationEvent.java 2012-07-10 13:41:55.000000000 +0400
@@ -28,6 +28,9 @@
import java.awt.ActiveEvent;
import java.awt.AWTEvent;
+import sun.awt.AWTAccessor;
+import sun.awt.AWTInterruptedException;
+
/**
* An event which executes the run()
method on a Runnable
*
when dispatched by the AWT event dispatcher thread. This class can
@@ -127,6 +130,16 @@
*/
private static final long serialVersionUID = 436056344909459450L;
+ static {
+ AWTAccessor.setInvocationEventAccessor(
+ new AWTAccessor.InvocationEventAccessor() {
+ @Override
+ public void dispose(InvocationEvent ie) {
+ ie.dispose();
+ }
+ });
+ }
+
/**
* Constructs an InvocationEvent
with the specified
* source which will execute the runnable's run
@@ -228,6 +241,19 @@
this.when = System.currentTimeMillis();
}
+ /*
+ * Marks the event as dispatched and notifies all interested parties.
+ */
+ private void setDispatched() {
+ dispatched = true;
+
+ if (notifier != null) {
+ synchronized (notifier) {
+ notifier.notifyAll();
+ }
+ }
+ }
+
/**
* Executes the Runnable's run()
method and notifies the
* notifier (if any) when run()
has returned or thrown an exception.
@@ -251,16 +277,18 @@
runnable.run();
}
} finally {
- dispatched = true;
-
- if (notifier != null) {
- synchronized (notifier) {
- notifier.notifyAll();
- }
- }
+ setDispatched();
}
}
+ private void dispose() {
+ throwable = exception =
+ new AWTInterruptedException(
+ "The event is discarded due to Event Thread interruption");
+
+ setDispatched();
+ }
+
/**
* Returns any Exception caught while executing the Runnable's run()
*
method.