org.xins.common
Class TimeOutController

java.lang.Object
  extended byorg.xins.common.TimeOutController

public final class TimeOutController
extends Object

Utility class for executing a task with a certain time-out period.

Since:
XINS 1.0.0
Version:
$Revision: 1.17 $ $Date: 2006/08/28 09:12:35 $
Author:
Ernst de Haan

Method Summary
static void execute(Runnable task, int timeOut)
          Runs the specified task with a specific time-out.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

execute

public static void execute(Runnable task,
                           int timeOut)
                    throws IllegalArgumentException,
                           IllegalThreadStateException,
                           SecurityException,
                           TimeOutException
Runs the specified task with a specific time-out. If the task does not finish within the specified time-out period, then the thread executing that task is interrupted using the Thread.interrupt() method and a TimeOutException is thrown.

Note that the specified task could be run either in the current thread or in a new thread. In the latter case, no initialization is performed. For example, the Nested Diagnostic Context identifier (NDC) is not copied from the current thread to the new one.

Parameters:
task - the task to run, cannot be null.
timeOut - the timeOut in milliseconds, must be > 0.
Throws:
IllegalArgumentException - if task == null || timeOut <= 0.
IllegalThreadStateException - if the specified task is a Thread that is already started.
SecurityException - if the thread did not finish within the total time-out period, but the interruption of the thread was disallowed (see Thread.interrupt()); consequently, the thread may still be running.
TimeOutException - if the thread did not finish within the total time-out period and was interrupted.


See http://www.xins.org/.