com.boylesoftware.cb2.util.pool
Class PooledThreadFactory

java.lang.Object
  extended bycom.boylesoftware.cb2.util.pool.PooledObjectFactoryAdapter
      extended bycom.boylesoftware.cb2.util.pool.PooledThreadFactory
All Implemented Interfaces:
PooledObjectFactory

public abstract class PooledThreadFactory
extends PooledObjectFactoryAdapter

Parent class for thread pool factories. When you are implementing a thread pool you implement a factory object extending this class and the pooled thread object extending the PooledThread class.

Version:
$Id: PooledThreadFactory.java,v 1.5 2003/08/29 13:08:53 levahim Exp $
Author:
Lev Himmelfarb

Field Summary
 
Fields inherited from class com.boylesoftware.cb2.util.pool.PooledObjectFactoryAdapter
pool
 
Constructor Summary
PooledThreadFactory(java.lang.String threadGroupName)
          Constructs the pool.
 
Method Summary
 java.lang.Object createObject()
          Creates a new instance of the pooled thread class and starts a thread on it.
protected abstract  PooledThread createPooledThread()
          User-defined method that creates a new instance of the pooled thread object.
 void destroyObject(java.lang.Object o)
          Kills a thread.
 
Methods inherited from class com.boylesoftware.cb2.util.pool.PooledObjectFactoryAdapter
resetObject, setPool
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PooledThreadFactory

public PooledThreadFactory(java.lang.String threadGroupName)
Constructs the pool. It must be called from your pool implementation's constructor.

Parameters:
threadGroupName - name of the thread group all threads in this pool will belong.
Method Detail

createObject

public final java.lang.Object createObject()
Creates a new instance of the pooled thread class and starts a thread on it.

Returns:
the new thread object instance.

createPooledThread

protected abstract PooledThread createPooledThread()
User-defined method that creates a new instance of the pooled thread object. The imlpementation should not start the thread, just create an instance of the class.

Returns:
the new pooled thread instance.

destroyObject

public void destroyObject(java.lang.Object o)
Kills a thread.

Specified by:
destroyObject in interface PooledObjectFactory
Overrides:
destroyObject in class PooledObjectFactoryAdapter
Parameters:
o - the thread to kill, should be instance of PooledThread or derived.


Copyright © 2002,2003,2004 - Boyle Software, Inc.