Search code examples
javaparallel-processingjmeterbeanshell

How to keep Thread variables in jmeter when multiple Threads are running in parallel?


I have my multiple threads Running in parallel. Any request can get fired from any thread that too multiple times. I have stored my request variables in beanshell using vars.put(). I have retrieved this variables in another beanshell using vars.get(). but when Thread runs in parallel , I want that while retriving a variable it should retrive the value which of current Thread. Somewhat like in java how we use this keyword and get current object's property. how can I do this?

int ThreadNum = ctx.getThreadNum();
String[] Request_values= new String[Request_variables.length];

how will I conacat the thread number to the Request_values?


Solution

  • you can put your string array using vars.putObject("",""); at thhis time you can concat your thread number at keyname.

    int ThreadNum = ctx.getThreadNum();
    String[] Request_values= new String[Request_variables.length];
    vars.putObject("Key_"+ThreadNum ,Request_values);