Author: noelgrandin
Date: Tue May 31 08:30:23 2011
New Revision: 1129568
URL: http://svn.apache.org/viewvc?rev=1129568&view=rev
Log:
PIVOT-747 pivot & blocking edt
make the checker installable
Modified:
pivot/trunk/wtk/src/org/apache/pivot/wtk/Container.java
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/Container.java
URL:
http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/Container.java?rev=1129568&r1=1129567&r2=1129568&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/Container.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/Container.java Tue May 31 08:30:23
2011
@@ -844,23 +844,35 @@ public abstract class Container extends
return containerMouseListeners;
}
- public static final void assertEventDispatchThread() {
- String threadName = Thread.currentThread().getName();
- /* Currently, application startup happens on the main thread, so we
need to allow
- * that thread to modify WTK state.
- */
- if (threadName.equals("main")) {
- return;
- }
- /*
- * See Sun/Oracle bug 6424157. There is a race condition where we can
be running on the event thread
- * but isDispatchThread() will return false.
- */
- if (threadName.startsWith("AWT-EventQueue-")) {
- return;
+ private static Runnable EDT_CHECKER = new Runnable() {
+ public void run() {
+ String threadName = Thread.currentThread().getName();
+ /* Currently, application startup happens on the main thread, so
we need to allow
+ * that thread to modify WTK state.
+ */
+ if (threadName.equals("main") ||
threadName.equals("javawsApplicationMain")) {
+ return;
+ }
+ /*
+ * See Sun/Oracle bug 6424157. There is a race condition where we
can be running on the event thread
+ * but isDispatchThread() will return false.
+ */
+ if (threadName.startsWith("AWT-EventQueue-")) {
+ return;
+ }
+ if (!java.awt.EventQueue.isDispatchThread()) {
+ throw new IllegalStateException("this method can only be
called from the AWT event dispatch thread");
+ }
}
- if (!java.awt.EventQueue.isDispatchThread()) {
- throw new IllegalStateException("this method can only be called
from the AWT event dispatch thread");
+ };
+
+ public static final void assertEventDispatchThread() {
+ if (EDT_CHECKER != null) {
+ EDT_CHECKER.run();
}
}
+
+ public static final void setEventDispatchThreadChecker(Runnable runnable) {
+ EDT_CHECKER = runnable;
+ }
}