Package org.apache.jmeter.threads

# Class JMeterThread

java.lang.Object
org.apache.jmeter.threads.JMeterThread

All Implemented Interfaces:
  `Runnable`, `Interruptible`

public class JMeterThread extends Object implements Runnable, Interruptible
The JMeter interface to the sampling process, allowing JMeter to see the timing, add listeners for sampling events and to stop the sampling process.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final String`
  `LAST_SAMPLE_OK`
  `static final String`
  `PACKAGE_OBJECT`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `JMeterThread(HashTree test, JMeterThreadMonitor monitor, ListenerNotifier note)`
  `JMeterThread(HashTree test, JMeterThreadMonitor monitor, ListenerNotifier note, Boolean isSameUserOnNextIteration)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected final void`
  `delayBy(long delay, String type)`
  Wait for delay with RAMPUP_GRANULARITY
  `long`
  `getEndTime()`
  Get the end time value.
  `ListenerNotifier`
  `getNotifier()`
  `long`
  `getStartTime()`
  Get the start time value.
  `ListedHashTree`
  `getTestTree()`
  `String`
  `getThreadName()`
  `int`
  `getThreadNum()`
  Returns the threadNum.
  `boolean`
  `interrupt()`
  Interrupt the current operation if possible.
  `void`
  `putVariables(JMeterVariables variables)`
  Updates the variables with all entries found in the variables in `vars`
  `void`
  `run()`
  `void`
  `setEndTime(long etime)`
  Set the EndTime for this Thread.
  `void`
  `setEngine(StandardJMeterEngine engine)`
  Save the engine instance for access to the stop methods
  `void`
  `setInitialContext(JMeterContext context)`
  Deprecated.
  `void`
  `setInitialDelay(int delay)`
  Set rampup delay for JMeterThread Thread
  `void`
  `setOnErrorStartNextLoop(boolean b)`
  Should Thread start next loop on Sampler error?
  `void`
  `setOnErrorStopTest(boolean b)`
  Should Test stop on sampler error?
  `void`
  `setOnErrorStopTestNow(boolean b)`
  Should Test stop abruptly on sampler error?
  `void`
  `setOnErrorStopThread(boolean b)`
  Should Thread stop on Sampler error?
  `void`
  `setScheduled(boolean sche)`
  Enable the scheduler for this JMeterThread.
  `void`
  `setStartTime(long stime)`
  Set the StartTime for this Thread.
  `void`
  `setThreadGroup(AbstractThreadGroup group)`
  `void`
  `setThreadName(String threadName)`
  `void`
  `setThreadNum(int threadNum)`
  Sets the threadNum.
  `void`
  `stop()`
  Set running flag to false which will interrupt JMeterThread on next flag test.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### PACKAGE_OBJECT

    public static final String PACKAGE_OBJECT
    See Also:
      - Constant Field Values

  - ### LAST_SAMPLE_OK

    public static final String LAST_SAMPLE_OK
    See Also:
      - Constant Field Values

- ## Constructor Details

  - ### JMeterThread

    public JMeterThread(HashTree test, JMeterThreadMonitor monitor, ListenerNotifier note)

  - ### JMeterThread

    public JMeterThread(HashTree test, JMeterThreadMonitor monitor, ListenerNotifier note, Boolean isSameUserOnNextIteration)

- ## Method Details

  - ### setInitialContext

    @Deprecated @API(status=DEPRECATED, since="5.5") public void setInitialContext(JMeterContext context)
    Deprecated.

  - ### putVariables

    @API(status=STABLE, since="5.5") public void putVariables(JMeterVariables variables)
    Updates the variables with all entries found in the variables in `vars`
    Parameters:
      `variables` - `JMeterVariables` with the entries to be updated

  - ### setScheduled

    public void setScheduled(boolean sche)
    Enable the scheduler for this JMeterThread.
    Parameters:
      `sche` - flag whether the scheduler should be enabled

  - ### setStartTime

    public void setStartTime(long stime)
    Set the StartTime for this Thread.
    Parameters:
      `stime` - the StartTime value.

  - ### getStartTime

    public long getStartTime()
    Get the start time value.
    Returns:
      the start time value.

  - ### setEndTime

    public void setEndTime(long etime)
    Set the EndTime for this Thread.
    Parameters:
      `etime` - the EndTime value.

  - ### getEndTime

    public long getEndTime()
    Get the end time value.
    Returns:
      the end time value.

  - ### setThreadName

    public void setThreadName(String threadName)

  - ### run

    public void run()
    Specified by:
      `run` in interface `Runnable`

  - ### getThreadName

    public String getThreadName()

  - ### stop

    public void stop()
    Set running flag to false which will interrupt JMeterThread on next flag test. This is a clean shutdown.

  - ### interrupt

    public boolean interrupt()
    Interrupt the current operation if possible.
    Specified by:
      `interrupt` in interface `Interruptible`
    Returns:
      `true` if there was an operation to interrupt.

  - ### setInitialDelay

    public void setInitialDelay(int delay)
    Set rampup delay for JMeterThread Thread
    Parameters:
      `delay` - Rampup delay for JMeterThread

  - ### delayBy

    protected final void delayBy(long delay, String type)
    Wait for delay with RAMPUP_GRANULARITY
    Parameters:
      `delay` - delay in ms
      `type` - Delay type

  - ### getThreadNum

    public int getThreadNum()
    Returns the threadNum.
    Returns:
      the threadNum

  - ### setThreadNum

    public void setThreadNum(int threadNum)
    Sets the threadNum.
    Parameters:
      `threadNum` - the threadNum to set

  - ### setEngine

    public void setEngine(StandardJMeterEngine engine)
    Save the engine instance for access to the stop methods
    Parameters:
      `engine` - the engine which is used

  - ### setOnErrorStopTest

    public void setOnErrorStopTest(boolean b)
    Should Test stop on sampler error?
    Parameters:
      `b` - true or false

  - ### setOnErrorStopTestNow

    public void setOnErrorStopTestNow(boolean b)
    Should Test stop abruptly on sampler error?
    Parameters:
      `b` - true or false

  - ### setOnErrorStopThread

    public void setOnErrorStopThread(boolean b)
    Should Thread stop on Sampler error?
    Parameters:
      `b` - true or false

  - ### setOnErrorStartNextLoop

    public void setOnErrorStartNextLoop(boolean b)
    Should Thread start next loop on Sampler error?
    Parameters:
      `b` - true or false

  - ### setThreadGroup

    public void setThreadGroup(AbstractThreadGroup group)

  - ### getTestTree

    public ListedHashTree getTestTree()
    Returns:
      `ListedHashTree`

  - ### getNotifier

    public ListenerNotifier getNotifier()
    Returns:
      `ListenerNotifier`