Package org.apache.jmeter.threads
Class ThreadGroup
java.lang.Object
org.apache.jmeter.testelement.AbstractTestElement
org.apache.jmeter.threads.AbstractThreadGroup
org.apache.jmeter.threads.ThreadGroup
- All Implemented Interfaces:
Serializable
,Cloneable
,Controller
,Searchable
,org.apache.jmeter.testelement.TestElement
,JMeterThreadMonitor
,TestCompilerHelper
- Direct Known Subclasses:
PostThreadGroup
,SetupThreadGroup
ThreadGroup holds the settings for a JMeter thread group.
This class is intended to be ThreadSafe.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.jmeter.testelement.TestElement
org.apache.jmeter.testelement.TestElement.Companion
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Scheduler start delay, overrides start timestatic final String
Whether thread startup is delayed until requiredstatic final String
Scheduler duration, overrides end timestatic final String
Ramp-up timestatic final String
Whether scheduler is being usedFields inherited from class org.apache.jmeter.threads.AbstractThreadGroup
DEFAULT_THREAD_STOP_TIMEOUT, IS_SAME_USER_ON_NEXT_ITERATION, MAIN_CONTROLLER, NUM_THREADS, ON_SAMPLE_ERROR, ON_SAMPLE_ERROR_CONTINUE, ON_SAMPLE_ERROR_START_NEXT_LOOP, ON_SAMPLE_ERROR_STOPTEST, ON_SAMPLE_ERROR_STOPTEST_NOW, ON_SAMPLE_ERROR_STOPTHREAD
Fields inherited from interface org.apache.jmeter.testelement.TestElement
COMMENTS, Companion, ENABLED, GUI_CLASS, NAME, TEST_CLASS
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionaddNewThread
(int delay, StandardJMeterEngine engine) Add a newJMeterThread
to thisThreadGroup
for enginelong
getDelay()
Get the startup delaylong
Get the desired duration of the thread group test run@NotNull org.apache.jmeter.testelement.schema.PropertiesAccessor<? extends ThreadGroup,
? extends org.apache.jmeter.threads.ThreadGroupSchema> getProps()
int
Get the ramp-up value.boolean
Get whether scheduler is being usedorg.apache.jmeter.threads.ThreadGroupSchema
int
void
setDelay
(long delay) Set the startup delayvoid
setDuration
(long duration) Set the desired duration of the thread group test runvoid
setRampUp
(int rampUp) Set the ramp-up value.void
setScheduler
(boolean scheduler) Set whether scheduler is being usedvoid
start
(int groupNum, ListenerNotifier notifier, ListedHashTree threadGroupTree, StandardJMeterEngine engine) Start theThreadGroup
void
stop()
This is a clean shutdown.boolean
stopThread
(String threadName, boolean now) Stop thread called threadName: stop JMeter thread interrupt JMeter thread interrupt underlying threadvoid
This is an immediate stop interrupting: current running threads current running samplers For each thread, invoke:JMeterThread.stop()
- set stop flagJMeterThread.interrupt()
- interrupt samplerThread.interrupt()
- interrupt JVM threadvoid
tellThreadsToStop
(boolean now) void
threadFinished
(JMeterThread thread) Called by JMeterThread when it finishesboolean
void
Wait for all Group Threads to stopMethods inherited from class org.apache.jmeter.threads.AbstractThreadGroup
addIterationListener, addTestElement, addTestElementOnce, breakThreadLoop, cloneTree, getNumberOfThreads, getNumThreads, getOnErrorStartNextLoop, getOnErrorStopTest, getOnErrorStopTestNow, getOnErrorStopThread, getSamplerController, initialize, isDone, isSameUserOnNextIteration, makeThread, next, removeIterationListener, setIsSameUserOnNextIteration, setNumThreads, setSamplerController, startNextLoop, triggerEndOfLoop
Methods inherited from class org.apache.jmeter.testelement.AbstractTestElement
addPropertiesValues, addProperty, addProperty, canRemove, clear, clearTemporary, clearTestElementChildren, clone, emptyTemporary, equals, getComment, getName, getProperty, getPropertyAsBoolean, getPropertyAsBoolean, getPropertyAsDouble, getPropertyAsFloat, getPropertyAsInt, getPropertyAsInt, getPropertyAsLong, getPropertyAsLong, getPropertyAsString, getPropertyAsString, getPropertyOrNull, getSearchableTokens, getThreadContext, getThreadName, hashCode, isEnabled, isRunningVersion, isTemporary, logProperties, mergeIn, propertyIterator, recoverRunningVersion, removeProperty, setComment, setEnabled, setName, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setRunningVersion, setTemporary, setThreadContext, setThreadName, traverse, traverseCollection, traverseMap, traverseProperty
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.jmeter.testelement.TestElement
canRemove, clear, clearTestElementChildren, clone, get, get, get, get, get, get, get, get, get, getComment, getName, getOrCreate, getOrCreate, getOrNull, getOrNull, getOrNull, getProperty, getPropertyAsBoolean, getPropertyAsBoolean, getPropertyAsDouble, getPropertyAsFloat, getPropertyAsInt, getPropertyAsInt, getPropertyAsLong, getPropertyAsLong, getPropertyAsString, getPropertyAsString, getPropertyOrNull, getPropertyOrNull, getString, getThreadContext, getThreadName, isEnabled, isRunningVersion, isTemporary, propertyIterator, recoverRunningVersion, removed, removeProperty, removeProperty, set, set, set, set, set, set, set, set, set, setComment, setEnabled, setName, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setRunningVersion, setTemporary, setThreadContext, setThreadName, traverse
-
Field Details
-
RAMP_TIME
Ramp-up time- See Also:
-
DELAYED_START
Whether thread startup is delayed until required- See Also:
-
SCHEDULER
Whether scheduler is being used- See Also:
-
DURATION
Scheduler duration, overrides end time- See Also:
-
DELAY
Scheduler start delay, overrides start time- See Also:
-
-
Constructor Details
-
ThreadGroup
public ThreadGroup()No-arg constructor.
-
-
Method Details
-
getSchema
public org.apache.jmeter.threads.ThreadGroupSchema getSchema()- Specified by:
getSchema
in interfaceorg.apache.jmeter.testelement.TestElement
- Overrides:
getSchema
in classAbstractThreadGroup
-
getProps
@NotNull public @NotNull org.apache.jmeter.testelement.schema.PropertiesAccessor<? extends ThreadGroup,? extends org.apache.jmeter.threads.ThreadGroupSchema> getProps()- Specified by:
getProps
in interfaceorg.apache.jmeter.testelement.TestElement
- Overrides:
getProps
in classAbstractThreadGroup
-
setScheduler
public void setScheduler(boolean scheduler) Set whether scheduler is being used- Parameters:
scheduler
- true is scheduler is to be used
-
getScheduler
public boolean getScheduler()Get whether scheduler is being used- Returns:
- true if scheduler is being used
-
getDuration
public long getDuration()Get the desired duration of the thread group test run- Returns:
- the duration (in secs)
-
setDuration
public void setDuration(long duration) Set the desired duration of the thread group test run- Parameters:
duration
- in seconds
-
getDelay
public long getDelay()Get the startup delay- Returns:
- the delay (in secs)
-
setDelay
public void setDelay(long delay) Set the startup delay- Parameters:
delay
- in seconds
-
setRampUp
public void setRampUp(int rampUp) Set the ramp-up value.- Parameters:
rampUp
- the ramp-up value.
-
getRampUp
public int getRampUp()Get the ramp-up value.- Returns:
- the ramp-up value.
-
start
public void start(int groupNum, ListenerNotifier notifier, ListedHashTree threadGroupTree, StandardJMeterEngine engine) Description copied from class:AbstractThreadGroup
Start theThreadGroup
- Specified by:
start
in classAbstractThreadGroup
- Parameters:
groupNum
- group numbernotifier
-ListenerNotifier
threadGroupTree
-ListedHashTree
engine
-StandardJMeterEngine
-
addNewThread
Description copied from class:AbstractThreadGroup
Add a newJMeterThread
to thisThreadGroup
for engine- Specified by:
addNewThread
in classAbstractThreadGroup
- Parameters:
delay
- Delay in millisecondsengine
-StandardJMeterEngine
- Returns:
JMeterThread
-
stopThread
Stop thread called threadName:- stop JMeter thread
- interrupt JMeter thread
- interrupt underlying thread
- Specified by:
stopThread
in classAbstractThreadGroup
- Parameters:
threadName
- String thread namenow
- boolean for stop- Returns:
- true if thread stopped
-
threadFinished
Called by JMeterThread when it finishes -
tellThreadsToStop
public void tellThreadsToStop(boolean now) -
tellThreadsToStop
public void tellThreadsToStop()This is an immediate stop interrupting:- current running threads
- current running samplers
JMeterThread.stop()
- set stop flagJMeterThread.interrupt()
- interrupt samplerThread.interrupt()
- interrupt JVM thread
- Specified by:
tellThreadsToStop
in classAbstractThreadGroup
-
stop
public void stop()This is a clean shutdown. For each thread, invoke:JMeterThread.stop()
- set stop flag
- Specified by:
stop
in classAbstractThreadGroup
-
numberOfActiveThreads
public int numberOfActiveThreads()- Specified by:
numberOfActiveThreads
in classAbstractThreadGroup
- Returns:
- number of active threads
-
verifyThreadsStopped
public boolean verifyThreadsStopped()- Specified by:
verifyThreadsStopped
in classAbstractThreadGroup
- Returns:
- boolean true if all threads stopped
-
waitThreadsStopped
public void waitThreadsStopped()Wait for all Group Threads to stop- Specified by:
waitThreadsStopped
in classAbstractThreadGroup
-