skip to Main Content

Im using the following code to stop a thread using jsr223 sampler on a specific condition.
Thread group.stop(Thread.currentThread.getname())
But the jmeter engine is ignoring the above condition and proceeding.
Can some one pls help on the right function.

Regards
Shankar

2

Answers


  1. The correct function would be

    ThreadGroup.stopThread(java.lang.String threadName, boolean now)

    Also be aware that JMeterThread is not the same as JVM Thread, i.e. they have different “names”.

    So you need to amend your code to look something like:

    ctx.getThreadGroup().stopThread(ctx.getThread().getThreadName(),true)
    

    where ctx is a shorthand for JMeterContext

    You can also check out The Groovy Templates Cheat Sheet for JMeter to learn what else could be done using Groovy scripting.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search