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