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


1 /*
2   File: DirectExecutor.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 */

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

23 public class DirectExecutor implements Executor {
24   /**
25    * Execute the given command directly in the current thread.
26    **/

27   public void execute(Runnable command) throws InterruptedException {
28     if (Thread.interrupted()) throw new InterruptedException();
29
30     command.run();
31   }
32 }
33

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