Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

alma::acs::container::CleaningDaemonThreadFactory Class Reference

Collaboration diagram for alma::acs::container::CleaningDaemonThreadFactory:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 CleaningDaemonThreadFactory (String name, Logger logger)
Thread newThread (Runnable command)
List< Thread > _getAllThreadsCreated ()
synchronized void cleanUp ()

Package Functions

void setNewThreadContextClassLoader (ClassLoader cl)

Private Member Functions

synchronized void ensureGroupCreated ()

Private Attributes

final List< Thread > threadList = new ArrayList<Thread>()
final AtomicInteger threadNumber = new AtomicInteger(1)
final Logger logger
final String name
LoggingThreadGroup group
ClassLoader newThreadContextCL

Detailed Description

Thread factory that remembers all threads it creates. Method cleanUp allows killing all threads.

A ThreadGroup is used to deal with all threads at a time. Its name is that given in the constructor. Even though Josh Bloch tells us in "Effective Java", Item 53, that thread groups are almost useless, we like the UncaughtExceptionHandler which JDK 1.4 only offers through ThreadGroups. TODO: revisit this in JDK 1.5 where Thread itself has this handler.

Author:
hsommer created Mar 8, 2005 1:27:38 PM


Constructor & Destructor Documentation

alma::acs::container::CleaningDaemonThreadFactory::CleaningDaemonThreadFactory String  name,
Logger  logger
[inline]
 

Constructor.

Parameters:
name the name of the ThreadGroup to which all threads created by this factory will belong.
logger the logger to be used by this class


Member Function Documentation

List<Thread> alma::acs::container::CleaningDaemonThreadFactory::_getAllThreadsCreated  )  [inline]
 

Gets a copy of the list of all threads created by this factory up to this call. This method should only be used for testing, but not in operational code.

synchronized void alma::acs::container::CleaningDaemonThreadFactory::cleanUp  )  [inline]
 

Kills running threads via Thread#interrupt() or Thread#stop(), see code comments about the two cases. Should be called by the container or similar classes when all threads created by this factory supposedly have terminated anyway thanks to smart applications. The safety concerns which led to the deprecation of the stop method thus don't seem to apply here.

synchronized void alma::acs::container::CleaningDaemonThreadFactory::ensureGroupCreated  )  [inline, private]
 

Thread alma::acs::container::CleaningDaemonThreadFactory::newThread Runnable  command  )  [inline]
 

Creates a new daemon thread that is part of the same factory thread group as all other threads created by this method. The thread's name will be that of the group, with an integer value appended.

See also:
java.util.concurrent.ThreadFactory#newThread(java.lang.Runnable)

void alma::acs::container::CleaningDaemonThreadFactory::setNewThreadContextClassLoader ClassLoader  cl  )  [inline, package]
 


Member Data Documentation

LoggingThreadGroup alma::acs::container::CleaningDaemonThreadFactory::group [private]
 

final Logger alma::acs::container::CleaningDaemonThreadFactory::logger [private]
 

final String alma::acs::container::CleaningDaemonThreadFactory::name [private]
 

ClassLoader alma::acs::container::CleaningDaemonThreadFactory::newThreadContextCL [private]
 

final List<Thread> alma::acs::container::CleaningDaemonThreadFactory::threadList = new ArrayList<Thread>() [private]
 

final AtomicInteger alma::acs::container::CleaningDaemonThreadFactory::threadNumber = new AtomicInteger(1) [private]
 


The documentation for this class was generated from the following file:
Generated on Thu Apr 30 02:52:26 2009 for ACS Java API by doxygen 1.3.8