org.starhope.appius.services
Class Charon

java.lang.Object
  extended by java.lang.Thread
      extended by org.starhope.appius.services.Charon
All Implemented Interfaces:
Runnable

public class Charon
extends Thread

Charon is the reaper for zombie threads. It just removes threads from the server to clear out the memory and process space and such — threadwise garbage collection.

Author:
brpocock@star-hope.org

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
private  Set<WeakReference<Thread>> restlessDead
          The set of threads who might be zombies
private static Charon theCharon
          the singleton instance
private  long threadJoinTimeout
          How long to wait for a zombie to join us before passing it over for this reaper pass
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
Charon()
           
 
Method Summary
 void addZombie(Thread t)
          Add a thread to the pool to be checked to reaping periodically
 void blog(String victim, String note)
          Write a log entry about someone
private  void blogThreadState(Thread t, String name)
          “blog” about the thread state
private  void excise()
          WRITEME: Document this method brpocock@star-hope.org
static Charon instance()
           
 void run()
          This is an overriding method.
 
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
 

Field Detail

restlessDead

private final Set<WeakReference<Thread>> restlessDead
The set of threads who might be zombies


threadJoinTimeout

private final long threadJoinTimeout
How long to wait for a zombie to join us before passing it over for this reaper pass


theCharon

private static Charon theCharon
the singleton instance

Constructor Detail

Charon

public Charon()
Method Detail

instance

public static Charon instance()
Returns:
the singleton instance

addZombie

public void addZombie(Thread t)
Add a thread to the pool to be checked to reaping periodically

Parameters:
t - The zombie thread to be checked for reaping

blog

public void blog(String victim,
                 String note)
Write a log entry about someone

Parameters:
victim - the thread's name
note - what we want to talk about

blogThreadState

private void blogThreadState(Thread t,
                             String name)
“blog” about the thread state

Parameters:
t - the thread whose state is to be examined
name - the name to use for blogging about it.

excise

private void excise()
WRITEME: Document this method brpocock@star-hope.org


run

public void run()
This is an overriding method.

Specified by:
run in interface Runnable
Overrides:
run in class Thread
See Also:
Thread.run()