JBoss Threads 2.0.0.GA-redhat-2

org.jboss.threads
Class JBossThread

java.lang.Object
  extended by java.lang.Thread
      extended by org.jboss.threads.JBossThread
All Implemented Interfaces:
Runnable

public final class JBossThread
extends Thread

A JBoss thread. Supports logging and extra operations.


Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
JBossThread(Runnable target)
          Construct a new instance.
JBossThread(Runnable target, String name)
          Construct a new instance.
JBossThread(ThreadGroup group, Runnable target)
          Construct a new instance.
JBossThread(ThreadGroup group, Runnable target, String name)
          Construct a new instance.
JBossThread(ThreadGroup group, Runnable target, String name, long stackSize)
          Construct a new instance.
 
Method Summary
static JBossThread currentThread()
          Get the current JBossThread, or null if the current thread is not a JBossThread.
static InterruptHandler getAndSetInterruptHandler(InterruptHandler newInterruptHandler)
          Swap the current thread's active interrupt handler.
 org.jboss.threads.ThreadNameInfo getThreadNameInfo()
          Get the thread name information.
 void interrupt()
          Interrupt this thread.
 void run()
          Execute the thread's Runnable.
 void setThreadNameInfo(org.jboss.threads.ThreadNameInfo threadNameInfo)
          Set the thread name information.
 void setUncaughtExceptionHandler(Thread.UncaughtExceptionHandler eh)
          Change the uncaught exception handler for this thread.
 void start()
          Start the thread.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, sleep, sleep, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JBossThread

public JBossThread(Runnable target)
Construct a new instance.

Parameters:
target - the runnable target
See Also:
#Thread(Runnable)

JBossThread

public JBossThread(Runnable target,
                   String name)
Construct a new instance.

Parameters:
target - the runnable target
name - the initial thread name
See Also:
#Thread(Runnable, String)

JBossThread

public JBossThread(ThreadGroup group,
                   Runnable target)
            throws SecurityException
Construct a new instance.

Parameters:
group - the parent thread group
target - the runnable target
Throws:
SecurityException - if the current thread cannot create a thread in the specified thread group
See Also:
#Thread(ThreadGroup, Runnable)

JBossThread

public JBossThread(ThreadGroup group,
                   Runnable target,
                   String name)
            throws SecurityException
Construct a new instance.

Parameters:
group - the parent thread group
target - the runnable target
name - the initial thread name
Throws:
SecurityException - if the current thread cannot create a thread in the specified thread group
See Also:
#Thread(ThreadGroup,Runnable,String)

JBossThread

public JBossThread(ThreadGroup group,
                   Runnable target,
                   String name,
                   long stackSize)
            throws SecurityException
Construct a new instance.

Parameters:
group - the parent thread group
target - the runnable target
name - the initial thread name
Throws:
SecurityException - if the current thread cannot create a thread in the specified thread group
See Also:
#Thread(ThreadGroup,Runnable,String,long)
Method Detail

interrupt

public void interrupt()
Interrupt this thread. Logs a trace message and calls the current interrupt handler, if any. The interrupt handler is called from the calling thread, not the thread being interrupted.

Overrides:
interrupt in class Thread

run

public void run()
Execute the thread's Runnable. Logs a trace message at the start and end of execution.

Specified by:
run in interface Runnable
Overrides:
run in class Thread

currentThread

public static JBossThread currentThread()
Get the current JBossThread, or null if the current thread is not a JBossThread.

Returns:
the current thread, or null

start

public void start()
Start the thread.

Overrides:
start in class Thread
Throws:
IllegalThreadStateException - if the thread was already started.

setUncaughtExceptionHandler

public void setUncaughtExceptionHandler(Thread.UncaughtExceptionHandler eh)
Change the uncaught exception handler for this thread.

Overrides:
setUncaughtExceptionHandler in class Thread
Parameters:
eh - the new handler

getAndSetInterruptHandler

public static InterruptHandler getAndSetInterruptHandler(InterruptHandler newInterruptHandler)
Swap the current thread's active interrupt handler. Most callers should restore the old handler in a finally block like this:
 InterruptHandler oldHandler = JBossThread.getAndSetInterruptHandler(newHandler);
 try {
     ...execute interrupt-sensitive operation...
 } finally {
     JBossThread.getAndSetInterruptHandler(oldHandler);
 }
 

Parameters:
newInterruptHandler - the new interrupt handler
Returns:
the old interrupt handler

getThreadNameInfo

public org.jboss.threads.ThreadNameInfo getThreadNameInfo()
Get the thread name information. This includes information about the thread's sequence number and so forth.

Returns:
the thread name info

setThreadNameInfo

public void setThreadNameInfo(org.jboss.threads.ThreadNameInfo threadNameInfo)
                       throws SecurityException
Set the thread name information. This includes information about the thread's sequence number and so forth.

Parameters:
threadNameInfo - the new thread name info
Throws:
SecurityException - if the calling thread is not allowed to modify this thread

JBoss Threads 2.0.0.GA-redhat-2

Copyright © 2012 JBoss by Red Hat. All Rights Reserved.