Reputation: 201
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?
Upvotes: 1
Views: 2274
Reputation: 95
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);
Upvotes: 2
Reputation: 168207
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.
Upvotes: 4