Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Beware of worker threads - link to web page



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.

It's here:
http://java.sun.com/developer/JDCTechTips/2005/tt0727.html#1

Dave


----------

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

References: 
 >Beware of worker threads (From: Matt Drance <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.