1
votes

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?

2

2 Answers

2
votes

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);
4
votes

JMeter Variables are basically ThreadLocal therefore you don't need to do anything.

If you need to access the value of variable of Thread 1 in Thread 2 you can use ${__threadNum} function as a prefix or postfix to append current thread number to the JMeter Variable name.