mandala.util
Class SafeThreadPool

java.lang.Object
  extended byjava.lang.ThreadGroup
      extended bymandala.util.ThreadPool
          extended bymandala.util.SafeThreadPool

public class SafeThreadPool
extends ThreadPool

Safe threads pool implementation with unlimited maximum bound.

This class extends the generic ThreadPool implementation which uses a fixed maximum amount of threads by default which may leads to deadlock.

Notice that the deadlock problem still theorically remains since a maximum amount of threads may be fixed by the system and is always bounds to a limit which depends on the available memory.

Version:
$Revision: 1.13 $
Author:
eipi
See Also:
ThreadGroup

Nested Class Summary
 
Nested classes inherited from class mandala.util.ThreadPool
ThreadPool.ThreadPoolCancelable
 
Field Summary
 
Fields inherited from class mandala.util.ThreadPool
daemonStatus, DEFAULT_DAEMON_STATUS, DEFAULT_MAX_THREADS_NB, DEFAULT_MAX_THREADS_NB_PROPERTY, DEFAULT_MIN_THREADS_NB, DEFAULT_MIN_THREADS_NB_PROPERTY, DEFAULT_PRIORITY, DEFAULT_PRIORITY_PROPERTY, DEFAULT_REACTIVITY_TIMER, DEFAULT_REACTIVITY_TIMER_PROPERTY, DEFAULT_SYSLOG, DELTA_PRIORITY, instancesNumber, max, min, priority, reactivity, syslog
 
Constructor Summary
SafeThreadPool()
          Creates a new SafeThreadPool instance.
SafeThreadPool(int min)
          Creates a new SafeThreadPool instance.
SafeThreadPool(String name)
          Creates a new SafeThreadPool instance.
SafeThreadPool(String name, int min)
          Creates a new SafeThreadPool instance.
SafeThreadPool(ThreadGroup parent, String name, int min)
          Creates a new SafeThreadPool instance.
SafeThreadPool(ThreadGroup parent, String name, int min, int priority, boolean daemonStatus, long reactivity)
          Creates a new SafeThreadPool instance.
 
Methods inherited from class mandala.util.ThreadPool
cancel, cancel, cancel, delete, execute, finalize, getDaemonStatus, getMax, getMin, getPriority, getReactivity, getSyslog, interrupt, interrupt, isStarted, setSyslog, start
 
Methods inherited from class java.lang.ThreadGroup
activeCount, activeGroupCount, allowThreadSuspension, checkAccess, destroy, enumerate, enumerate, enumerate, enumerate, getMaxPriority, getName, getParent, interrupt, isDaemon, isDestroyed, list, parentOf, resume, setDaemon, setMaxPriority, stop, suspend, toString, uncaughtException
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SafeThreadPool

public SafeThreadPool(String name)

Creates a new SafeThreadPool instance.

Equivalent to SafeThreadPool(name, DEFAULT_MIN_THREADS_NB).

Parameters:
name - the name of the new thread pool.

SafeThreadPool

public SafeThreadPool()

Creates a new SafeThreadPool instance.

Equivalent to SafeThreadPool(DEFAULT_MIN_THREADS_NB).


SafeThreadPool

public SafeThreadPool(int min)

Creates a new SafeThreadPool instance.

Equivalent to SafeThreadPool(gname, min). where gname is where gname is a newly generated name. Automatically generated names are of the form SafeThreadPool.class.getName() + "#" + n, where n is an integer.


SafeThreadPool

public SafeThreadPool(String name,
                      int min)

Creates a new SafeThreadPool instance.

Equivalent to SafeThreadPool(Thread.currentThread().getThreadGroup(), name, min).


SafeThreadPool

public SafeThreadPool(ThreadGroup parent,
                      String name,
                      int min)

Creates a new SafeThreadPool instance.

Equivalent to SafeThreadPool(parent, name, min, DEFAULT_PRIORITY, DEFAULT_DAEMON_STATUS, DEFAULT_REACTIVITY_TIMER).


SafeThreadPool

public SafeThreadPool(ThreadGroup parent,
                      String name,
                      int min,
                      int priority,
                      boolean daemonStatus,
                      long reactivity)

Creates a new SafeThreadPool instance.

The created instance has parent as parent's thread group, name as name and an initial pool of min threads. It may allocate an unlimited number of threads if needed. The threads in the pool will be assigned to the given priority and daemonStatus. The thread-balancer will have the given reactivity

Parameters:
parent - the parent thread group.
name - the name of the new thread pool.
min - the minimum amount of pre-allocated threads in this thread pool.
priority - the priority given to new threads in this pool.
daemonStatus - the daemon status given to new threads in this pool.
reactivity - the reactivity given to the thread-balancer of this pool.



Mandala help mailing list