org.sapia.ubik.net
Class PooledThread

java.lang.Object
  extended by java.lang.Thread
      extended by org.sapia.ubik.net.PooledThread
All Implemented Interfaces:
java.lang.Runnable
Direct Known Subclasses:
SocketRmiServerThread

public abstract class PooledThread
extends java.lang.Thread

Implements a pooled thread. Inheriting classes need only implementing the doExec template method.

Author:
Yanick Duchesne
Copyright:
Copyright © 2002-2003 Sapia Open Source Software. All Rights Reserved.
License:
Read the license.txt file of the jar or visit the license page at the Sapia OSS web site
See Also:
ThreadPool, doExec(Object)

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
protected  Statistic _duration
           
protected  HitsPerSecStatistic _tps
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
protected PooledThread()
           
 
Method Summary
protected abstract  void doExec(java.lang.Object task)
          Executes the "task" passed in, which is an arbitrary application-specific unit of work that this method performs.
 void exec(java.lang.Object task)
          Sets this pool's task, which represents a unit of work to perform.
protected abstract  void handleExecutionException(java.lang.Exception e)
           
 void run()
           
 void shutdown()
          Stops this thread.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, 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
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_tps

protected HitsPerSecStatistic _tps

_duration

protected Statistic _duration
Constructor Detail

PooledThread

protected PooledThread()
Method Detail

exec

public final void exec(java.lang.Object task)
Sets this pool's task, which represents a unit of work to perform. This wakes up the thread, which then calls its own doExec method.

See Also:
doExec(Object)

shutdown

public void shutdown()
Stops this thread.


run

public final void run()
Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

doExec

protected abstract void doExec(java.lang.Object task)
Executes the "task" passed in, which is an arbitrary application-specific unit of work that this method performs. In fact, it will probably be, in most cases, some data on which this method's implementation will perform some actions. If the object passed in is eventually shared between multiple threads, it should provide a proper thread-safe behavior.

This template method is to be implemented by subclasses.

Parameters:
a - task to execute, or data on which this method should act.

handleExecutionException

protected abstract void handleExecutionException(java.lang.Exception e)


Copyright © 2010 Sapia OSS. All Rights Reserved.