NetKernel APIs


com.ten60.netkernel.scheduler
Class WorkerThreadPool

java.lang.Object
  extended bycom.ten60.netkernel.scheduler.WorkerThreadPool

public abstract class WorkerThreadPool
extends Object

A ProcessofThreadGroup is a homogeneous collection of ProcessorThreads which can be managed as a group. This includes start/stop/suspend/resume. But also the groups size can be change dynamically.


Field Summary
protected  ArrayList mProcessorThreads
          The set of active threads in this group
 
Constructor Summary
WorkerThreadPool(String aName, int aInitialThreads, ThreadGroup aParentGroup)
          Creates a new ProcessorThreadGroup.
 
Method Summary
protected  WorkerThread createNewThread(ThreadGroup aThisGroup)
          Abstract method to instantiate a new instance of a subclass of ProcessorThread to be added to this group.
 int getActualThreadCount()
          The count of the number of actual threads in this group.
 int getSetThreadCount()
           
 ThreadGroup getThreadGroup()
          Returns the real java ThreadGroup object for this group.
 void join(long aTimeout)
          Wait for all threads in group to stop.
abstract  void process()
           
 void replace(Thread aThread)
          The given thread will be removed from the thread pool and replaced with a fresh one
 void setCount(int aThreadCount)
          Dynamically changes the number of active threads within this group.
 void start()
          Starts all the threads in the group.
 void stop()
          Requests that all the threads in the group are stopped.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mProcessorThreads

protected final ArrayList mProcessorThreads
The set of active threads in this group

Constructor Detail

WorkerThreadPool

public WorkerThreadPool(String aName,
                        int aInitialThreads,
                        ThreadGroup aParentGroup)
Creates a new ProcessorThreadGroup.

Parameters:
aName - The name that the real java ThreadGroup will be given
aInitialThreads - The initial number of threads that this group will have.
aParentGroup - parent thread group
Method Detail

getThreadGroup

public ThreadGroup getThreadGroup()
Returns the real java ThreadGroup object for this group.

Returns:
The java.lang.ThreadGroup.

setCount

public void setCount(int aThreadCount)
Dynamically changes the number of active threads within this group. It is valid to call this method at any time before the group is stopped.

Parameters:
aThreadCount - The desired number of active threads for the group.

getActualThreadCount

public int getActualThreadCount()
The count of the number of actual threads in this group.

Returns:
The count of the number of active threads in this group.

getSetThreadCount

public int getSetThreadCount()

createNewThread

protected WorkerThread createNewThread(ThreadGroup aThisGroup)
Abstract method to instantiate a new instance of a subclass of ProcessorThread to be added to this group.

Parameters:
aThisGroup - The ThreadGroup that the new thread should belong to.
Returns:
The newly created ProcessorThread.

start

public void start()
Starts all the threads in the group.


stop

public void stop()
Requests that all the threads in the group are stopped.


join

public void join(long aTimeout)
          throws InterruptedException
Wait for all threads in group to stop.

Parameters:
aTimeout - time to wait for threads before killing them
Throws:
InterruptedException - Thrown if we are interrupted whilst waiting for the threads to die.

replace

public void replace(Thread aThread)
The given thread will be removed from the thread pool and replaced with a fresh one

Parameters:
aThread - the thread to replace

process

public abstract void process()
                      throws InterruptedException
Throws:
InterruptedException

NetKernel APIs


Copyright © 2002-2004 1060 Research Ltd. All Rights Reserved.