Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.gui > #5080

Re: [ANN] java.awt.SecondaryLoop

From markspace <-@.>
Newsgroups comp.lang.java.gui
Subject Re: [ANN] java.awt.SecondaryLoop
Date 2012-03-06 08:28 -0800
Organization A noiseless patient Spider
Message-ID <jj5duq$sk9$1@dont-email.me> (permalink)
References <jj3qo1$47l$1@dont-email.me> <j49h29-ld4.ln1@s.simpson148.btinternet.com>

Show all headers | View raw


On 3/6/2012 3:30 AM, Steven Simpson wrote:
> When you click A, it greys out for 5
> seconds; B for 10 seconds. If you click A then B before A is restored, A
> has to wait for B to complete. It seems that A's SL simply re-enters the
> event loop, so the second click is handled by that invocation, and must
> re-enter the loop again. They can only unwind in reverse order.
>
> Am I doing it wrong?


I get the same result as you, and I don't see any errors in the code.  I 
think there may be a queuing system for the various threads.

For example, if you start with an original event thread O, and then 
create event thread A, which then creates event thread B, it's easy to 
see that there might be some sort stack or queue that stores each 
thread, and that the most recent one has to return to the next most 
recent.  In this example, B could not arbitrarily return to O.  It's A 
that is waiting on B to exit, so we have to return to A's "enter()" 
method first before anything else can happen.

Remember from the docs that this was designed to support modal dialogue 
boxes.  A main thread creates a single dialog box.  That dialog box 
creates a modal secondary dialog.  It's easy to see in this example that 
the secondary modal dialog would need to return to the first, and then 
the first has to be dismissed before the user can return to the main 
window.  That appears to be the sort of behavior that SecondaryLoop is 
designed to support.

If you need more arbitrary behavior, use SwingWorker.  They have their 
own done() method which doesn't return, it just executes arbitrary code 
on the EDT.  Their execute() method doesn't block, so you can run as 
many as you like in any order, and it doesn't matter (other than for any 
dependencies you create).

Back to comp.lang.java.gui | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[ANN] java.awt.SecondaryLoop Jeff Higgins <jeff@invalid.invalid> - 2012-03-05 20:54 -0500
  Re: [ANN] java.awt.SecondaryLoop markspace <-@.> - 2012-03-05 23:19 -0800
  Re: [ANN] java.awt.SecondaryLoop Steven Simpson <ss@domain.invalid> - 2012-03-06 11:30 +0000
    Re: [ANN] java.awt.SecondaryLoop markspace <-@.> - 2012-03-06 08:28 -0800
      Re: [ANN] java.awt.SecondaryLoop Steven Simpson <ss@domain.invalid> - 2012-03-06 17:00 +0000
        Re: [ANN] java.awt.SecondaryLoop markspace <-@.> - 2012-03-06 10:23 -0800
    Re: [ANN] java.awt.SecondaryLoop Jeff Higgins <jeff@invalid.invalid> - 2012-03-06 12:07 -0500
      Re: [ANN] java.awt.SecondaryLoop markspace <-@.> - 2012-03-06 10:25 -0800

csiph-web