Re: invokeLater and weird race conditions in my swing app
On 10 Sep, 10:16, Roedy Green <see_webs...@mindprod.com.invalid>
On Sun, 09 Sep 2007 23:58:50 -0700, ap...@student.open.ac.uk wrote,
quoted or indirectly quoted someone who said :
SwingWorker, only appeared officially in java 6 which
I cannot use. Why so late in the day?
You can use SwingUtilities.invokeLater which gives you the core
functionality. It has been around at least since 1.4.
No, this is only half the story. invokeLater is for when I am not in
the EDT and need to make a call to swing. But there is also the case
when I am the EDT (invoked via a callback) and need to do something
that is non-swing related. For that I need SwingWorker.
You don't necessarily need SwingWorker. All you need is any old Runnable which
offloads the processing task from the EDT. SwingWorker is just a convenience
wrapper (admittedly, very convenient) for the functionality you require.
See this link from the comp.lang.java.gui FAQ. The second link is referenced in
the first, and points to a previous version of SwingWorker which might work in
1.5. I don't know, I've not tried that version. I still use the one from the
old tutorials in 1.5 code.
Nigel Wade, System Administrator, Space Plasma Physics Group,
University of Leicester, Leicester, LE1 7RH, UK
E-mail : firstname.lastname@example.org
Phone : +44 (0)116 2523548, Fax : +44 (0)116 2523555