Title: Re: Beware of worker threads - link to web
page
At 5:08 PM -0700 2005-07-27, Matt Drance wrote:
Hi all,
For those who don't subscribe to the Java
Tech Tips newsletter, I'm passing this along. It talks about a
pitfall to the otherwise good practice of pushing busy work off the
AWT thread.
Create
Threads for Long Tasks From the Event Dispatch
Thread
Here's
the situation: you want to spin off a thread from the event queue to
do a long task. If your event handler needs to do a long task, you
don't want to block the event thread. So you create a new thread for
the long task, and call
invokeLater() when the task
is done to handle the results on the event thread. Here's the typical
usage pattern:
public void actionPerformed(ActionEvent
e) {
Runnable longTask = new
Runnable() {
public void run()
{
etc.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden
This email sent to email@hidden