KickJava    Java API By Example, From Geeks To Geeks. A to Z  | News  | Codes  | Search  | BooksFree  | Blogs  | Forum |
Remove Ad

121 WOW!

FREE Magazines




Code - Class EDU.oswego.cs.dl.util.concurrent.ThreadedExecutor


1 /*
2   File: ThreadedExecutor.java
3
4   Originally written by Doug Lea and released into the public domain.
5   This may be used for any purposes whatsoever without acknowledgment.
6   Thanks for the assistance and support of Sun Microsystems Labs,
7   and everyone contributing, testing, and using this code.
8
9   History:
10   Date Who What
11   21Jun1998 dl Create public version
12   28aug1998 dl factored out ThreadFactoryUser
13 */

14
15 package EDU.oswego.cs.dl.util.concurrent;
16
17 /**
18  *
19  * An implementation of Executor that creates a new
20  * Thread that invokes the run method of the supplied command.
21  *
22  * <p>[<a HREF="http://gee.cs.oswego.edu/dl/classes/EDU/oswego/cs/dl/util/concurrent/intro.html"> Introduction to this package. </a>]
23  **/

24 public class ThreadedExecutor extends ThreadFactoryUser implements Executor {
25
26   /**
27    * Execute the given command in a new thread.
28    **/

29   public synchronized void execute(Runnable command) throws InterruptedException {
30     if (Thread.interrupted())
31       throw new InterruptedException();
32
33     Thread thread = getThreadFactory().newThread(command);
34     thread.start();
35   }
36 }
37

Bookmark  |digg |del.icio.us |furl |spurl |blinklist |reddit |yahoo |blinkbits |blogmarks |de.lirio.us |smarking |


Java API By Example, From Geeks To Geeks. | Conditions of Use | About Us © 2002 - 2005, KickJava.com, or its affiliates