org.apache.avalon.excalibur.pool.test
Class LatchedThreadGroup
java.lang.Object
org.apache.avalon.framework.logger.AbstractLogEnabled
org.apache.avalon.excalibur.pool.test.LatchedThreadGroup
- All Implemented Interfaces:
- LogEnabled
- public class LatchedThreadGroup
- extends AbstractLogEnabled
This class is useful for writing MultiThreaded test cases where you need to perform multithreaded load testing on a component.
An instance of will create a block of threads of the specified size. Each thread will be assigned to run a specified Runnable instance. The threads will then all wait at a latch until the go method is called. The go method will not return until all of the Runnables have completed.
- Version:
- $Id: LatchedThreadGroup.java,v 1.2 2004/03/29 16:50:37 mcconnell Exp $
- Author:
| Constructor Summary |
LatchedThreadGroup(java.lang.Runnable[] runnables)
Creates a LatchedThreadGroup with a thread for each Runnable in the runnables array. |
LatchedThreadGroup(java.lang.Runnable runnable, int threadCount)
Creates a LatchedThreadGroup with threadCount threads each running runnable. |
| Method Summary |
private Logger |
getInnerLogger()
Inner access method to getLogger() to work around a bug in the Javac compiler when getLogger() is called from the method of an inner class. |
long |
go()
Causes all of the Runnables to start at the same instance. |
protected void |
resetMemory()
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
m_threads
private java.lang.Thread[] m_threads
-
m_semaphore
private java.lang.Object m_semaphore
-
m_startedCount
private int m_startedCount
-
m_latched
private boolean m_latched
-
m_completedCount
private int m_completedCount
-
m_exception
private java.lang.Throwable m_exception
-
LatchedThreadGroup
public LatchedThreadGroup(java.lang.Runnable[] runnables)
-
Creates a LatchedThreadGroup with a thread for each Runnable in the runnables array.
LatchedThreadGroup
public LatchedThreadGroup(java.lang.Runnable runnable,
int threadCount)
-
Creates a LatchedThreadGroup with threadCount threads each running runnable.
resetMemory
protected void resetMemory()
-
go
public long go()
throws java.lang.Exception
-
Causes all of the Runnables to start at the same instance. This method will return once all of the Runnables have completed.
-
- Returns:
- time, in milliseconds, that it took for all of the Runnables to complete.
- Throws:
java.lang.Exception
getInnerLogger
private Logger getInnerLogger()
-
Inner access method to getLogger() to work around a bug in the Javac compiler when getLogger() is called from the method of an inner class. Jikes seems to handle it Ok. :-/
-
Please see keelframework.org for information about new Keel releases.