[ https://issues.apache.org/jira/browse/PIVOT-747?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13038370#comment-13038370 ]
Andrei Pozolotin commented on PIVOT-747: ---------------------------------------- Noel, hello again! 1) I think I found the reason why your isDispatchThread() blows up on push() / pop(): 2) both push and pop are synchronized : public synchronized void push(EventQueue newEventQueue) { synchronized (newEventQueue) { protected void pop() throws EmptyStackException { synchronized ((prev != null) ? prev : this) { synchronized(this) { 3) but isDispatchThread() is not synchronized, hence it can see all kind of transitory phases; public static boolean isDispatchThread() { EventQueue eq = Toolkit.getEventQueue(); EventQueue next = eq.nextQueue; while (next != null) { eq = next; next = eq.nextQueue; } return (Thread.currentThread() == eq.dispatchThread); } for example I have a test case which, with proper timing, blows up both source and target EDT threads during push/pop switch! :-) 4) so it seems, if you insist on EventQueue Pivot Police ® :-) we would need a better isDispatchThread() implementatoion; 5) bottom line: isDispatchThread() is a good guard for EDT vs non-EDT, but does not work for EDT vs EDT; Cheers, Andrei. > pivot & blocking edt > -------------------- > > Key: PIVOT-747 > URL: https://issues.apache.org/jira/browse/PIVOT-747 > Project: Pivot > Issue Type: Improvement > Components: wtk > Affects Versions: 2.0 > Reporter: Andrei Pozolotin > Attachments: patch-001-exit.patch > > > Greg, hello; > in this thread: > http://mail-archives.apache.org/mod_mbox/pivot-user/201001.mbox/%3c4b5e581d.2080...@hms.harvard.edu%3E > your final word is: > "Sorry, it is not possible" > but I know that you know that it is possible :-) > the reason I need this is same as Martin here: > http://netbeans.org/bugzilla/show_bug.cgi?id=90590 > namely: do some cleanup after shutdown was requested and confirmed: > org.apache.pivot.wtk.Application > public boolean shutdown(boolean optional) throws Exception; > since you call shutdown(boolean optional) from EDT I need to block it, using > this approach: > http://bugs.sun.com/view_bug.do?bug_id=6424157 > wich "almost works", except you have this check everywhere: > Container.assertEventDispatchThread(); > which fails, as described above: > http://bugs.sun.com/view_bug.do?bug_id=6424157 > due to EventQueue.isDispatchThread() failing on the "T1 vs T1*" distinction > my request is this: > do you think you could make > Container.assertEventDispatchThread(); > less pedantic, and allow both "current and past/next" EDT threads to pass > which are created during EventQueue push() / pop() > thanks! > Andrei -- This message is automatically generated by JIRA. For more information on JIRA, see: http://www.atlassian.com/software/jira