com.xinapse.util
Class CancellableThread

java.lang.Object
  extended by java.lang.Thread
      extended by com.xinapse.util.CancellableThread
All Implemented Interfaces:
java.lang.Runnable

public class CancellableThread
extends java.lang.Thread

A class to implement a cancellable Thread. Thread cancellation is achieved by setting the flag. It is up to the thread's run method to check this flag periodically and return if set.


Nested Class Summary
static class CancellableThread.Flag
          A flag that can be set to indicate that a cancellation has taken place.
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
protected  CancellableThread.Flag flag
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
CancellableThread()
           
 
Method Summary
 void cancel()
          Signal the CancellableThread to stop any processing and return.
 boolean isCancelled()
          Tests whether this CancellableThread has been cancelled.
 
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

flag

protected CancellableThread.Flag flag
Constructor Detail

CancellableThread

public CancellableThread()
Method Detail

cancel

public void cancel()
Signal the CancellableThread to stop any processing and return.


isCancelled

public boolean isCancelled()
Tests whether this CancellableThread has been cancelled.



Copyright 2006-2011 Xinapse Systems Limited. All Rights Reserved.