public static void execute(Runnable task, int timeOut) throws IllegalArgumentException, IllegalThreadStateException, SecurityException, TimeOutException
Thread.interrupt()method and a
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
timeOut- the timeOut in milliseconds, must be > 0.
task == null || timeOut <= 0.
IllegalThreadStateException- if the specified task is a
Threadthat 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.