edu.emory.mathcs.util.concurrent
Class ThreadUtils

java.lang.Object
  extended byedu.emory.mathcs.util.concurrent.ThreadUtils

public class ThreadUtils
extends java.lang.Object

Low-level thread access utilities.

Version:
1.0
Author:
Dawid Kurzyniec

Method Summary
static Future asyncDestroyThreadGroup(java.lang.ThreadGroup tg, boolean suicide, Callback cb, java.lang.ThreadDeath cause)
           
static Future asyncDestroyThreadGroup(java.lang.ThreadGroup tg, Callback cb)
           
static Future asyncDestroyThreadGroup(java.lang.ThreadGroup tg, Callback cb, java.lang.ThreadDeath cause)
           
static Future asyncDestroyThreadGroup(java.lang.ThreadGroup tg, java.lang.Thread[] waitFor, Callback cb, java.lang.ThreadDeath cause)
           
static Future asyncResumeThreadGroup(java.lang.ThreadGroup tg, java.lang.Thread[] exclude, Callback cb)
           
static Future asyncStopThreadGroup(java.lang.ThreadGroup tg, boolean suicide, Callback cb, java.lang.ThreadDeath cause)
           
static Future asyncStopThreadGroup(java.lang.ThreadGroup tg, Callback cb)
           
static Future asyncStopThreadGroup(java.lang.ThreadGroup tg, java.lang.Thread[] exclude, Callback cb, java.lang.ThreadDeath cause)
           
static Future asyncSuspendThreadGroup(java.lang.ThreadGroup tg, boolean suicide, Callback cb)
           
static Future asyncSuspendThreadGroup(java.lang.ThreadGroup tg, java.lang.Thread[] exclude, Callback cb)
           
static boolean destroyThreadGroup(java.lang.ThreadGroup tg, long timeout)
           
static boolean destroyThreadGroup(java.lang.ThreadGroup tg, long timeout, boolean suicide, java.lang.ThreadDeath cause)
           
static boolean destroyThreadGroup(java.lang.ThreadGroup tg, long timeout, java.lang.Thread[] waitFor, java.lang.ThreadDeath cause)
           
static boolean destroyThreadGroup(java.lang.ThreadGroup tg, long timeout, java.lang.ThreadDeath cause)
           
static java.lang.ThreadGroup getTopLevelThreadGroup()
          Returns the root thread group.
static boolean isTerminated(java.lang.Thread thread)
           
static void resumeThread(java.lang.Thread t)
           
static boolean resumeThreadGroup(java.lang.ThreadGroup tg, long timeout, java.lang.Thread[] exclude)
           
static void stopThread(java.lang.Thread t)
          Stops specified thread.
static boolean stopThread(java.lang.Thread t, long timeout, java.lang.ThreadDeath cause)
          Stops specified thread with specified timeout and cause.
static void stopThread(java.lang.Thread t, java.lang.ThreadDeath cause)
          Stops specified thread with specified cause.
static boolean stopThreadGroup(java.lang.ThreadGroup tg, long timeout)
           
static boolean stopThreadGroup(java.lang.ThreadGroup tg, long timeout, boolean suicide, java.lang.ThreadDeath cause)
           
static boolean stopThreadGroup(java.lang.ThreadGroup tg, long timeout, java.lang.Thread[] exclude, java.lang.ThreadDeath cause)
           
static boolean suspendThread(java.lang.Thread t)
           
static boolean suspendThreadGroup(java.lang.ThreadGroup tg, long timeout, boolean suicide)
           
static boolean suspendThreadGroup(java.lang.ThreadGroup tg, long timeout, java.lang.Thread[] exclude)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getTopLevelThreadGroup

public static java.lang.ThreadGroup getTopLevelThreadGroup()
Returns the root thread group.

Returns:
the root thread group

stopThread

public static void stopThread(java.lang.Thread t)
Stops specified thread.

Parameters:
t - the thread to stop

stopThread

public static void stopThread(java.lang.Thread t,
                              java.lang.ThreadDeath cause)
Stops specified thread with specified cause.

Parameters:
t - the thread to stop
cause - the stop cause

isTerminated

public static boolean isTerminated(java.lang.Thread thread)

stopThread

public static boolean stopThread(java.lang.Thread t,
                                 long timeout,
                                 java.lang.ThreadDeath cause)
                          throws java.lang.InterruptedException
Stops specified thread with specified timeout and cause.

Parameters:
t - the thread to stop
timeout - number of milliseconds to wait for stop to complete
cause - the stop cause
Returns:
true if thread was stopped within the specified timeout, false otherwise.
Throws:
java.lang.InterruptedException

suspendThread

public static boolean suspendThread(java.lang.Thread t)

resumeThread

public static void resumeThread(java.lang.Thread t)

destroyThreadGroup

public static boolean destroyThreadGroup(java.lang.ThreadGroup tg,
                                         long timeout)
                                  throws java.lang.InterruptedException,
                                         ExecutionException,
                                         TimeoutException
Throws:
java.lang.InterruptedException
ExecutionException
TimeoutException

asyncDestroyThreadGroup

public static Future asyncDestroyThreadGroup(java.lang.ThreadGroup tg,
                                             Callback cb)

destroyThreadGroup

public static boolean destroyThreadGroup(java.lang.ThreadGroup tg,
                                         long timeout,
                                         java.lang.ThreadDeath cause)
                                  throws java.lang.InterruptedException,
                                         ExecutionException,
                                         TimeoutException
Throws:
java.lang.InterruptedException
ExecutionException
TimeoutException

asyncDestroyThreadGroup

public static Future asyncDestroyThreadGroup(java.lang.ThreadGroup tg,
                                             Callback cb,
                                             java.lang.ThreadDeath cause)

destroyThreadGroup

public static boolean destroyThreadGroup(java.lang.ThreadGroup tg,
                                         long timeout,
                                         boolean suicide,
                                         java.lang.ThreadDeath cause)
                                  throws java.lang.InterruptedException,
                                         ExecutionException,
                                         TimeoutException
Throws:
java.lang.InterruptedException
ExecutionException
TimeoutException

asyncDestroyThreadGroup

public static Future asyncDestroyThreadGroup(java.lang.ThreadGroup tg,
                                             boolean suicide,
                                             Callback cb,
                                             java.lang.ThreadDeath cause)

destroyThreadGroup

public static boolean destroyThreadGroup(java.lang.ThreadGroup tg,
                                         long timeout,
                                         java.lang.Thread[] waitFor,
                                         java.lang.ThreadDeath cause)
                                  throws java.lang.InterruptedException,
                                         ExecutionException,
                                         TimeoutException
Throws:
java.lang.InterruptedException
ExecutionException
TimeoutException

asyncDestroyThreadGroup

public static Future asyncDestroyThreadGroup(java.lang.ThreadGroup tg,
                                             java.lang.Thread[] waitFor,
                                             Callback cb,
                                             java.lang.ThreadDeath cause)

stopThreadGroup

public static boolean stopThreadGroup(java.lang.ThreadGroup tg,
                                      long timeout)
                               throws java.lang.InterruptedException,
                                      ExecutionException,
                                      TimeoutException
Throws:
java.lang.InterruptedException
ExecutionException
TimeoutException

asyncStopThreadGroup

public static Future asyncStopThreadGroup(java.lang.ThreadGroup tg,
                                          Callback cb)

stopThreadGroup

public static boolean stopThreadGroup(java.lang.ThreadGroup tg,
                                      long timeout,
                                      boolean suicide,
                                      java.lang.ThreadDeath cause)
                               throws java.lang.InterruptedException,
                                      ExecutionException,
                                      TimeoutException
Throws:
java.lang.InterruptedException
ExecutionException
TimeoutException

asyncStopThreadGroup

public static Future asyncStopThreadGroup(java.lang.ThreadGroup tg,
                                          boolean suicide,
                                          Callback cb,
                                          java.lang.ThreadDeath cause)

stopThreadGroup

public static boolean stopThreadGroup(java.lang.ThreadGroup tg,
                                      long timeout,
                                      java.lang.Thread[] exclude,
                                      java.lang.ThreadDeath cause)
                               throws java.lang.InterruptedException,
                                      ExecutionException,
                                      TimeoutException
Throws:
java.lang.InterruptedException
ExecutionException
TimeoutException

asyncStopThreadGroup

public static Future asyncStopThreadGroup(java.lang.ThreadGroup tg,
                                          java.lang.Thread[] exclude,
                                          Callback cb,
                                          java.lang.ThreadDeath cause)

suspendThreadGroup

public static boolean suspendThreadGroup(java.lang.ThreadGroup tg,
                                         long timeout,
                                         boolean suicide)
                                  throws java.lang.InterruptedException,
                                         ExecutionException,
                                         TimeoutException
Throws:
java.lang.InterruptedException
ExecutionException
TimeoutException

asyncSuspendThreadGroup

public static Future asyncSuspendThreadGroup(java.lang.ThreadGroup tg,
                                             boolean suicide,
                                             Callback cb)

suspendThreadGroup

public static boolean suspendThreadGroup(java.lang.ThreadGroup tg,
                                         long timeout,
                                         java.lang.Thread[] exclude)
                                  throws java.lang.InterruptedException,
                                         ExecutionException,
                                         TimeoutException
Throws:
java.lang.InterruptedException
ExecutionException
TimeoutException

asyncSuspendThreadGroup

public static Future asyncSuspendThreadGroup(java.lang.ThreadGroup tg,
                                             java.lang.Thread[] exclude,
                                             Callback cb)

resumeThreadGroup

public static boolean resumeThreadGroup(java.lang.ThreadGroup tg,
                                        long timeout,
                                        java.lang.Thread[] exclude)
                                 throws java.lang.InterruptedException,
                                        ExecutionException,
                                        TimeoutException
Throws:
java.lang.InterruptedException
ExecutionException
TimeoutException

asyncResumeThreadGroup

public static Future asyncResumeThreadGroup(java.lang.ThreadGroup tg,
                                            java.lang.Thread[] exclude,
                                            Callback cb)