org.crosswire.common.util
Class ThreadUtil

java.lang.Object
  extended by org.crosswire.common.util.ThreadUtil

public final class ThreadUtil
extends Object

Various utilities for examining the running Threads and controlling their execution.

Author:
Joe Walker [joe at eireneh dot com]
See Also:
for license details.
The copyright to this program is held by it's authors.

Field Summary
private static String PADDING
           
 
Constructor Summary
private ThreadUtil()
          Prevent Instansiation
 
Method Summary
private static void addItem(List list, int depth, String item)
          Private, used by getListing.
static ThreadGroup findRoot()
          Find the root ThreadGroup by ascending the Thread tree
static String[] getListing()
          Create a StringArray (mostly for debugging) detailing the current Threads, starting at the root ThreadGroup
static String[] getListing(ThreadGroup base)
          Create a StringArray (mostly for debugging) detailing the current Threads, starting at the specified ThreadGroup
private static void listThread(List list, int depth, Thread thread)
          Private, used by getListing.
private static void listThreads(List list, int depth, ThreadGroup group)
          Private, used by getListing.
static void soundSleep(long millis)
          Sleep and don't think about throwing.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PADDING

private static final String PADDING
See Also:
Constant Field Values
Constructor Detail

ThreadUtil

private ThreadUtil()
Prevent Instansiation

Method Detail

soundSleep

public static void soundSleep(long millis)
Sleep and don't think about throwing. Mostly when a thread calls sleep you need to wrap it in a special try-catch block to get hold of the InterruptedException - which is rarely called and mostly ignored. This code takes care of the ignoring, and simply logs some stuff if InterruptedException do happen.

Parameters:
millis - The length of time to wait in milliseconds
See Also:
InterruptedException

findRoot

public static ThreadGroup findRoot()
Find the root ThreadGroup by ascending the Thread tree

Returns:
The root ThreadGroup

getListing

public static String[] getListing()
Create a StringArray (mostly for debugging) detailing the current Threads, starting at the root ThreadGroup

Returns:
The listing for all sub threads

getListing

public static String[] getListing(ThreadGroup base)
Create a StringArray (mostly for debugging) detailing the current Threads, starting at the specified ThreadGroup

Parameters:
base - The ThreadGroup to detail
Returns:
The listing for all sub threads

listThreads

private static void listThreads(List list,
                                int depth,
                                ThreadGroup group)
Private, used by getListing. Adds to a List the sub-threads

Parameters:
list - The List to add to.
depth - The current recursion depth
group - The ThreadGroup to detail

listThread

private static void listThread(List list,
                               int depth,
                               Thread thread)
Private, used by getListing. Adds to a List the sub-threads

Parameters:
list - The List to add to.
depth - The current recursion depth
thread - The Thread to detail

addItem

private static void addItem(List list,
                            int depth,
                            String item)
Private, used by getListing. Adds to a List the sub-threads

Parameters:
list - The List to add to.
depth - The current recursion depth

Copyright ? 2003-2006