textbender.g.lang
Class ThreadX

java.lang.Object
  extended by java.lang.Thread
      extended by ThreadX
All Implemented Interfaces:
Runnable

public final class ThreadX
extends Thread

Thread extensions and utilities.


Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
static Thread.UncaughtExceptionHandler UNCAUGHT_EXCEPTION_LOGGER
          A handler that logs uncaught errors and exceptions using the thread's associated logger.
static Thread.UncaughtExceptionHandler UNCAUGHT_EXCEPTION_PRINTER
          A handler that prints stack traces of uncaught errors and exceptions to the standard error stream.
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
ThreadX()
           
ThreadX(Runnable target)
           
ThreadX(Runnable target, String name)
           
ThreadX(ThreadGroup threadGroup, Runnable target, String name)
           
 
Method Summary
 boolean tryJoin()
          Same as join(), but returns normally if interrupted.
 boolean tryJoin(long milliseconds)
          Same as join(milliseconds), but returns normally if interrupted.
static boolean trySleep(long milliseconds)
          Same as sleep(milliseconds), but an interruption merely cuts short the sleep.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, run, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

UNCAUGHT_EXCEPTION_LOGGER

public static final Thread.UncaughtExceptionHandler UNCAUGHT_EXCEPTION_LOGGER
A handler that logs uncaught errors and exceptions using the thread's associated logger.


UNCAUGHT_EXCEPTION_PRINTER

public static final Thread.UncaughtExceptionHandler UNCAUGHT_EXCEPTION_PRINTER
A handler that prints stack traces of uncaught errors and exceptions to the standard error stream. Similar to the default behaviour of ThreadGroup.uncaughtException.

Constructor Detail

ThreadX

public ThreadX()

ThreadX

public ThreadX(Runnable target)

ThreadX

public ThreadX(Runnable target,
               String name)

ThreadX

public ThreadX(ThreadGroup threadGroup,
               Runnable target,
               String name)
Method Detail

tryJoin

public boolean tryJoin()
Same as join(), but returns normally if interrupted.

Returns:
true if the wait ended normally; false if an InterruptedException occured

tryJoin

public boolean tryJoin(long milliseconds)
Same as join(milliseconds), but returns normally if interrupted.

Returns:
true if the wait ended normally; false if an InterruptedException occured

trySleep

public static boolean trySleep(long milliseconds)
Same as sleep(milliseconds), but an interruption merely cuts short the sleep.