de.netseeker.ejoe.concurrent
Class Jdk15ThreadPool

java.lang.Object
  extended by de.netseeker.ejoe.concurrent.Jdk15ThreadPool
All Implemented Interfaces:
ThreadService

public class Jdk15ThreadPool
extends java.lang.Object
implements ThreadService

Fixed size thread pool implementation for usage with java >= 1.5.0

Since:
0.3.9.1
Author:
netseeker

Constructor Summary
Jdk15ThreadPool()
           
Jdk15ThreadPool(int numberOfThreads)
           
Jdk15ThreadPool(java.lang.ThreadGroup threadGroup)
           
Jdk15ThreadPool(java.lang.ThreadGroup threadGroup, int numberOfThreads)
           
 
Method Summary
 int getActiveWorkerCount()
          Returns the amount of worker threads which are active.
 int getCurrentPoolsize()
          Returns the amount of workers which are really usable in the underlying ThreadPool.
 int getExpectedPoolsize()
          Returns the amount of workers the ThreadService expects to to have in the underlying ThreadPool according to the currently active pool size.
 void invokeLater(java.lang.Runnable task)
          Queues a new task for asynchronous execution in the underlying ThreadPool
 void resize(int poolSize)
          Resizes the amount of worker threads in the ThreadService to the given size.
 void stop()
          Shutdown the underlying ThreadPool
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Jdk15ThreadPool

public Jdk15ThreadPool()

Jdk15ThreadPool

public Jdk15ThreadPool(int numberOfThreads)
Parameters:
numberOfThreads -

Jdk15ThreadPool

public Jdk15ThreadPool(java.lang.ThreadGroup threadGroup)
Parameters:
threadGroup -

Jdk15ThreadPool

public Jdk15ThreadPool(java.lang.ThreadGroup threadGroup,
                       int numberOfThreads)
Parameters:
threadGroup -
numberOfThreads -
Method Detail

getActiveWorkerCount

public int getActiveWorkerCount()
Description copied from interface: ThreadService
Returns the amount of worker threads which are active. Hereby "active" means the worker is currently executing a task.

Specified by:
getActiveWorkerCount in interface ThreadService
Returns:
the amount of currently active workers in the underlying ThreadPool

getCurrentPoolsize

public int getCurrentPoolsize()
Description copied from interface: ThreadService
Returns the amount of workers which are really usable in the underlying ThreadPool. The amount can differ from ThreadService.getExpectedPoolsize() caused by crashed (or due to too less memory unstarted) worker threads.

Specified by:
getCurrentPoolsize in interface ThreadService
Returns:
the amount of really usable worker threads in the underlying ThreadPool

getExpectedPoolsize

public int getExpectedPoolsize()
Description copied from interface: ThreadService
Returns the amount of workers the ThreadService expects to to have in the underlying ThreadPool according to the currently active pool size.

Specified by:
getExpectedPoolsize in interface ThreadService
Returns:
the amount of workers which should be started in the underlying ThreadPool

invokeLater

public void invokeLater(java.lang.Runnable task)
Description copied from interface: ThreadService
Queues a new task for asynchronous execution in the underlying ThreadPool

Specified by:
invokeLater in interface ThreadService
Parameters:
task - a task to execute within one of the available worker threads

resize

public void resize(int poolSize)
Description copied from interface: ThreadService
Resizes the amount of worker threads in the ThreadService to the given size.

Specified by:
resize in interface ThreadService
Parameters:
poolSize - the new amount of worker threads in the ThreadService

stop

public void stop()
Description copied from interface: ThreadService
Shutdown the underlying ThreadPool

Specified by:
stop in interface ThreadService


Copyright © 2005-2007 netseeker. All Rights Reserved.