com.ibm.jvm
Class InterruptibleThread

java.lang.Object
  extended by java.lang.Thread
      extended by com.ibm.jvm.InterruptibleThread
All Implemented Interfaces:
java.lang.Runnable

public class InterruptibleThread
extends java.lang.Thread

InterruptibleThread is a utility class that extends java.lang.Thread, to allow the wrapping of interruptible runnable methods. Use InterruptibleThread instead of java.lang.Thread when you instantiate a thread, if you might need to unblock that thread from a synchronization or networking operation.

You can use InterruptibleThread to check if a thread is being blocked on a synchronization or networking call. If the thread is blocked it can then be unblocked if required.

It uses instances of classes InterruptibleLockContext and InterruptibleIOContext to perform the required isblocked() and unblock() methods depending upon whether a synchronization or networking operation is blocking the thread.


Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
InterruptibleThread()
          Allocates a new InterruptibleThread object and calls it's superclass constructor.
InterruptibleThread(java.lang.Runnable runnable)
          Allocates a new InterruptibleThread object.
InterruptibleThread(java.lang.Runnable runnable, java.lang.String threadName)
          Allocates a new InterruptibleThread object.
InterruptibleThread(java.lang.String threadName)
          Allocates a new InterruptibleThread object.
InterruptibleThread(java.lang.ThreadGroup group, java.lang.Runnable runnable)
          Allocates a new InterruptibleThread object.
InterruptibleThread(java.lang.ThreadGroup group, java.lang.Runnable runnable, java.lang.String threadName)
          Allocates a new InterruptibleThread object.
InterruptibleThread(java.lang.ThreadGroup group, java.lang.Runnable runnable, java.lang.String threadName, long stack)
          Allocates a new InterruptibleThread object.
InterruptibleThread(java.lang.ThreadGroup group, java.lang.String threadName)
          Allocates a new InterruptibleThread object.
 
Method Summary
 boolean isBlocked()
          Checks to see if the OS thread is blocked on a synchronized or networking call.
 void run()
          Calls its superclass's run method and then contructs an InterruptibleIOContext and InterruptibleLockContext object, which are used by calls to isBlocked() and unBlock(), depending on whether the thread is blocking on a synchronization or networking call.
 void unBlock()
          Break the associated OS thread out of the blocking synchronization or networking call.
 
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, 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
 

Constructor Detail

InterruptibleThread

public InterruptibleThread()
Allocates a new InterruptibleThread object and calls it's superclass constructor.

See Also:
Thread

InterruptibleThread

public InterruptibleThread(java.lang.Runnable runnable)
Allocates a new InterruptibleThread object. The constructor just calls its superclass constructor.

Parameters:
runnable - the object whose run method is called.
See Also:
Thread, Thread.Thread(Runnable runnable)

InterruptibleThread

public InterruptibleThread(java.lang.Runnable runnable,
                           java.lang.String threadName)
Allocates a new InterruptibleThread object. The constructor just calls its superclass constructor.

Parameters:
runnable - the object whose run method is called.
threadName - the name of the new thread.
See Also:
Thread, Thread.Thread(Runnable runnable, String threadName)

InterruptibleThread

public InterruptibleThread(java.lang.String threadName)
Allocates a new InterruptibleThread object. The constructor just calls its superclass constructor.

Parameters:
threadName - the name of the new thread.
See Also:
Thread, Thread.Thread(String threadName)

InterruptibleThread

public InterruptibleThread(java.lang.ThreadGroup group,
                           java.lang.Runnable runnable)
Allocates a new InterruptibleThread object. The constructor just calls its superclass constructor.

Parameters:
group - the thread group.
runnable - the object whose run method is called.
See Also:
Thread, Thread.Thread(ThreadGroup group, Runnable runnable)

InterruptibleThread

public InterruptibleThread(java.lang.ThreadGroup group,
                           java.lang.Runnable runnable,
                           java.lang.String threadName)
Allocates a new InterruptibleThread object. The constructor just calls its superclass constructor.

Parameters:
group - the thread group.
runnable - the object whose run method is called.
threadName - the name of the new thread.
See Also:
Thread, Thread.Thread(ThreadGroup group, Runnable runnable, String threadName)

InterruptibleThread

public InterruptibleThread(java.lang.ThreadGroup group,
                           java.lang.Runnable runnable,
                           java.lang.String threadName,
                           long stack)
Allocates a new InterruptibleThread object. The constructor just calls its superclass constructor.

Parameters:
group - the thread group.
runnable - the object whose run method is called.
threadName - the name of the new thread.
stack - stack size for the new thread, or zero if the parameter is to be ignored.
See Also:
Thread, Thread.Thread(ThreadGroup group, Runnable runnable, String threadName, long stack)

InterruptibleThread

public InterruptibleThread(java.lang.ThreadGroup group,
                           java.lang.String threadName)
Allocates a new InterruptibleThread object. The constructor just calls its superclass constructor.

Parameters:
group - the thread group.
threadName - the name of the new thread.
See Also:
Thread, Thread.Thread(ThreadGroup group, String threadName)
Method Detail

run

public void run()
Calls its superclass's run method and then contructs an InterruptibleIOContext and InterruptibleLockContext object, which are used by calls to isBlocked() and unBlock(), depending on whether the thread is blocking on a synchronization or networking call.

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread
See Also:
Thread

isBlocked

public boolean isBlocked()
Checks to see if the OS thread is blocked on a synchronized or networking call.

Returns:
true if OS thread is blocked false otherwise.

unBlock

public void unBlock()
Break the associated OS thread out of the blocking synchronization or networking call.