org.oddjob.util
Class SimpleThreadManager

java.lang.Object
  extended by org.oddjob.util.SimpleThreadManager
All Implemented Interfaces:
ThreadManager

public class SimpleThreadManager
extends Object
implements ThreadManager

The thread manager keeps track of active threads. It can be used to ensure that all threads are complete before a job terminates.


Constructor Summary
SimpleThreadManager()
          Default Constructor.
SimpleThreadManager(ExecutorService executors)
          Constructor uses provided ExecutorService.
 
Method Summary
 String[] activeDescriptions()
          Return a array of the descriptions of all active threads.
 void close()
          Close the ThreadManager and free resource.
 void run(Runnable runnable, String description)
          Run a job.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SimpleThreadManager

public SimpleThreadManager()
Default Constructor. Uses a default ExecutorService.


SimpleThreadManager

public SimpleThreadManager(ExecutorService executors)
Constructor uses provided ExecutorService.

Parameters:
executors -
Method Detail

run

public void run(Runnable runnable,
                String description)
Run a job.

Specified by:
run in interface ThreadManager
Parameters:
runnable - The job.
description - The description of the job.

activeDescriptions

public String[] activeDescriptions()
Return a array of the descriptions of all active threads. The description of the thread making the request is excluded. This is because method is used to see if a server can stop, so a server can run a job which stops itself.

Specified by:
activeDescriptions in interface ThreadManager
Returns:
A list of descriptions.

toString

public String toString()
Overrides:
toString in class Object

close

public void close()
Description copied from interface: ThreadManager
Close the ThreadManager and free resource. This may involve interrupting Threads or similar to ensure nothing is still running.

Specified by:
close in interface ThreadManager