Deprecated
Use QueuedThreadPool
Avoids the expense of thread creation by pooling threads after their run methods exit for reuse.
If the maximum pool size is reached, jobs wait for a free thread. By default there is no maximum pool size. Idle threads timeout and terminate until the minimum number of threads are running.
| Modifier and Type | Class and Description |
|---|---|
| public class | BoundedThreadPool.PoolThread
Pool Thread class. |
| Modifier and Type | Field and Description |
|---|---|
| private static int | |
| private boolean | |
| private int | |
| private List | |
| private final Object | |
| private long | |
| private final Object | |
| pack-priv int | |
| private int | |
| private int | |
| private int | |
| private String | |
| pack-priv int | |
| private List | |
| private Set | |
| private boolean |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | |
| protected void | |
| protected void | |
| public int | Returns: Number of threadsImplements org. |
| public int | |
| public int | |
| public int | |
| public int | |
| public String | |
| public int | |
| public int | Returns: Number of threadsImplements org. |
| public int | |
| public boolean | |
| public boolean | |
| public void | |
| protected BoundedThreadPool. | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| protected void |
| __id | back to summary |
|---|---|
| private static int __id | |
| _daemon | back to summary |
|---|---|
| private boolean _daemon | |
| _id | back to summary |
|---|---|
| private int _id | |
| _idle | back to summary |
|---|---|
| private List<E> _idle | |
| _joinLock | back to summary |
|---|---|
| private final Object _joinLock | |
| _lastShrink | back to summary |
|---|---|
| private long _lastShrink | |
| _lock | back to summary |
|---|---|
| private final Object _lock | |
| _lowThreads | back to summary |
|---|---|
| pack-priv int _lowThreads | |
| _maxIdleTimeMs | back to summary |
|---|---|
| private int _maxIdleTimeMs | |
| _maxThreads | back to summary |
|---|---|
| private int _maxThreads | |
| _minThreads | back to summary |
|---|---|
| private int _minThreads | |
| _name | back to summary |
|---|---|
| private String _name | |
| _priority | back to summary |
|---|---|
| pack-priv int _priority | |
| _queue | back to summary |
|---|---|
| private List<E> _queue | |
| _threads | back to summary |
|---|---|
| private Set<E> _threads | |
| _warned | back to summary |
|---|---|
| private boolean _warned | |
| BoundedThreadPool | back to summary |
|---|---|
| public BoundedThreadPool() | |
| dispatch | back to summary |
|---|---|
| public boolean dispatch(Runnable job) Implements org. Run job.
| |
| doStart | back to summary |
|---|---|
| protected void doStart() throws Exception | |
| doStop | back to summary |
|---|---|
| protected void doStop() throws Exception Overrides org. Stop the BoundedThreadPool. New jobs are no longer accepted,idle threads are interrupted and stopJob is called on active threads. The method then waits min(getMaxStopTimeMs(),getMaxIdleTimeMs()), for all jobs to stop, at which time killJob is called. | |
| getIdleThreads | back to summary |
|---|---|
| public int getIdleThreads() Implements org. Get the number of idle threads in the pool.
| |
| getLowThreads | back to summary |
|---|---|
public int getLowThreads()
| |
| getMaxIdleTimeMs | back to summary |
|---|---|
| public int getMaxIdleTimeMs() Get the maximum thread idle time. Delegated to the named or anonymous Pool.
| |
| getMaxThreads | back to summary |
|---|---|
| public int getMaxThreads() Set the maximum number of threads. Delegated to the named or anonymous Pool.
| |
| getMinThreads | back to summary |
|---|---|
| public int getMinThreads() Get the minimum number of threads. Delegated to the named or anonymous Pool.
| |
| getName | back to summary |
|---|---|
public String getName()
| |
| getQueueSize | back to summary |
|---|---|
| public int getQueueSize() | |
| getThreads | back to summary |
|---|---|
| public int getThreads() Implements org. Get the number of threads in the pool.
| |
| getThreadsPriority | back to summary |
|---|---|
| public int getThreadsPriority() Get the priority of the pool threads.
| |
| isDaemon | back to summary |
|---|---|
| public boolean isDaemon() Delegated to the named or anonymous Pool. | |
| isLowOnThreads | back to summary |
|---|---|
| public boolean isLowOnThreads() Implements org.
| |
| join | back to summary |
|---|---|
| public void join() throws InterruptedException Implements org. Doc from org. Blocks until the thread pool is | |
| newThread | back to summary |
|---|---|
| protected BoundedThreadPool. | |
| setDaemon | back to summary |
|---|---|
| public void setDaemon(boolean daemon) Delegated to the named or anonymous Pool. | |
| setLowThreads | back to summary |
|---|---|
public void setLowThreads(int lowThreads)
| |
| setMaxIdleTimeMs | back to summary |
|---|---|
| public void setMaxIdleTimeMs(int maxIdleTimeMs) Set the maximum thread idle time. Threads that are idle for longer than this period may be stopped. Delegated to the named or anonymous Pool.
| |
| setMaxThreads | back to summary |
|---|---|
| public void setMaxThreads(int maxThreads) Set the maximum number of threads. Delegated to the named or anonymous Pool.
| |
| setMinThreads | back to summary |
|---|---|
| public void setMinThreads(int minThreads) Set the minimum number of threads. Delegated to the named or anonymous Pool.
| |
| setName | back to summary |
|---|---|
public void setName(String name)
| |
| setThreadsPriority | back to summary |
|---|---|
| public void setThreadsPriority(int priority) Set the priority of the pool threads.
| |
| stopJob | back to summary |
|---|---|
| protected void stopJob(Thread thread, Object job) Stop a Job. This method is called by the Pool if a job needs to be stopped. The default implementation does nothing and should be extended by a derived thread pool class if special action is required. | |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv Runnable |
| Access | Constructor and Description |
|---|---|
| pack-priv | |
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv void | |
| public void |
| _job | back to summary |
|---|---|
| pack-priv Runnable _job | |
| PoolThread | back to summary |
|---|---|
| pack-priv PoolThread() | |
| PoolThread | back to summary |
|---|---|
| pack-priv PoolThread(Runnable job) | |
| dispatch | back to summary |
|---|---|
| pack-priv void dispatch(Runnable job) | |
| run | back to summary |
|---|---|
| public void run() Overrides java. Implements java. BoundedThreadPool run. Loop getting jobs and handling them until idle or stopped. | |