org.apache.jmeter.threads

## Class JMeterContextService

- java.lang.Object
- - org.apache.jmeter.threads.JMeterContextService

-     public final class JMeterContextService
      extends Object

  Provides context service for JMeter threads. Keeps track of active and total thread counts.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `JMeterContextService.ThreadCounts`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static void` | `addTotalThreads(int thisGroup)` Update the total number of threads
    `static void` | `clearTotalThreads()` Set total threads to zero; also clears started and finished counts
    `static void` | `endTest()` Called by MainFrame#testEnded().
    `static JMeterContext` | `getContext()` Gives access to the current thread context.
    `static int` | `getNumberOfThreads()` Get the number of currently active threads
    `static long` | `getTestStartTime()`
    `static JMeterContextService.ThreadCounts` | `getThreadCounts()`
    `static int` | `getTotalThreads()` Get the total number of threads (>= active)
    `static void` | `replaceContext(JMeterContext context)` Replace Thread Context by the parameter.
    `static void` | `startTest()` Method is called by the JMeterEngine class when a test run is started.

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

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

- - ### Method Detail

    - #### getContext

          public static JMeterContext getContext()

      Gives access to the current thread context.
      Returns:
        the current thread Context

    - #### replaceContext

          public static void replaceContext(JMeterContext context)

      Replace Thread Context by the parameter. Currently only used by the private class `ASyncSample` in `HTTPSamplerBase`
      Parameters:
        `context` - `JMeterContext`

    - #### startTest

          public static void startTest()

      Method is called by the JMeterEngine class when a test run is started. Zeroes numberOfActiveThreads. Saves current time in a field and in the JMeter property "TESTSTART.MS"

    - #### getNumberOfThreads

          public static int getNumberOfThreads()

      Get the number of currently active threads
      Returns:
        active thread count

    - #### getThreadCounts

          public static JMeterContextService.ThreadCounts getThreadCounts()

    - #### endTest

          public static void endTest()

      Called by MainFrame#testEnded(). Clears start time field.

    - #### getTestStartTime

          public static long getTestStartTime()

    - #### getTotalThreads

          public static int getTotalThreads()

      Get the total number of threads (>= active)
      Returns:
        total thread count

    - #### addTotalThreads

          public static void addTotalThreads(int thisGroup)

      Update the total number of threads
      Parameters:
        `thisGroup` - number of threads in this thread group

    - #### clearTotalThreads

          public static void clearTotalThreads()

      Set total threads to zero; also clears started and finished counts

Copyright © 1998-2017 Apache Software Foundation. All Rights Reserved.