com.ibm.jvm

Class InterruptibleThread

  1. java.lang.Object
  2. extended byjava.lang.Thread
  3. extended bycom.ibm.jvm.InterruptibleThread
All implemented interfaces:
java.lang.Runnable

  1. public class InterruptibleThread
  2. 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

Constructor and Description
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

Modifier and Type Method and Description
  1. boolean
isBlocked()
Checks to see if the OS thread is blocked on a synchronized or networking call.
  1. 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.
  1. 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

  1. public InterruptibleThread()
Allocates a new InterruptibleThread object and calls it's superclass constructor.
See Also:
Thread

InterruptibleThread

  1. 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

  1. public InterruptibleThread(java.lang.Runnable runnable,
  2. 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

  1. 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

  1. public InterruptibleThread(java.lang.ThreadGroup group,
  2. 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

  1. public InterruptibleThread(java.lang.ThreadGroup group,
  2. java.lang.Runnable runnable,
  3. 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

  1. public InterruptibleThread(java.lang.ThreadGroup group,
  2. java.lang.Runnable runnable,
  3. java.lang.String threadName,
  4. 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

  1. public InterruptibleThread(java.lang.ThreadGroup group,
  2. 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

  1. 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

  1. 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

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