public final class TimeOutController extends Object
public static void execute(Runnable task, int timeOut) throws IllegalArgumentException, IllegalThreadStateException, SecurityException, TimeOutException
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.
task
- the task to run, cannot be null
.timeOut
- the timeOut in milliseconds, must be > 0.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/.