Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.crosswire.common.util
Class ThreadUtil

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

    public class ThreadUtil

extends Object

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

Distribution Licence: JSword is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2 as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. The License is available on the internet here, or by writing to: Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA The copyright to this program is held by it's authors.

Version:
  $Id: ThreadUtil.java,v 1.5 2005/03/19 18:45:07 dmsmith Exp $
Author:
  Joe Walker [joe at eireneh dot com]
See Also:
  `Licence`

Field Summary
`private static String` | `PADDING`

Constructor Summary
`private` | `ThreadUtil()` Prevent Instansiation

Method Summary
`private static void` | `addItem(List vec, 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 vec, int depth, Thread thread)` Private, used by getListing.
`private static void` | `listThreads(List vec, 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 vec,
                                    int depth,
                                    ThreadGroup group)

  Private, used by getListing. Adds to a Vector the sub-threads

  Parameters:
    `vec` - The Vector to add to.
    `depth` - The current recursion depth
    `group` - The ThreadGroup to detail

### listThread

    private static void listThread(List vec,
                                   int depth,
                                   Thread thread)

  Private, used by getListing. Adds to a Vector the sub-threads

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

### addItem

    private static void addItem(List vec,
                                int depth,
                                String item)

  Private, used by getListing. Adds to a Vector the sub-threads

  Parameters:
    `vec` - The List to add to.
    `depth` - The current recursion depth

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Copyright ? 2003-2004
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD