Hi variables arent shared across threads (even in the same thread group) Properties are shared , but when you use multiple threads then you need some way to synchronize access so that only one thread increments the counter at any one time. You could do this with Beanshell , but possibly it will be simpler to write a java class that holds a static counter that increments synchronously and just call it in a beanshell function to give you your number (avoids having the sampler in your results).
However the first question to ask is why do you need actually this ? or do you know how many numbers you need in advance (or a maximum) ? if you do then you can just generate a CSV file before you run your test(as part of your ant build or as a separate threadgroup or something) that has the numbers and use a CSV data set config (you can choose the sharing mode option that says all threads or current thread group) regards deepak On Thu, Dec 9, 2010 at 2:50 PM, Josh Abts <[email protected]> wrote: > Hello all, > > So I am a little confused with how variables are working in a single Thread > Group. > > I have attached a "User Defined Variables" config element to my thread > group. From there I setup a HTTP Request sampler under the thread group. > I > also under the thread group have a BeanShell Sampler with a script that > basically acts as a special counter to modify the User defined variables > that are used in the Http request. > > But when I run the test using say 3 threads and 1 loop, it only makes 3 > http > requests using the same value of the variable (the initial). If I run it > with 1 thread and 3 loops, it works as intended, giving 3 different values > properly incremented by the BeanShell sampler. > > In reading I ran across something that mentioned using JMeter Properties to > share values between threads. But even with that I am still not able to > get > it to properly use the values. > > What is the proper/best way to have a shared value among all the threads so > that it increments properly? And is a BeanShell sampler the proper way to > ensure it increments properly? I am using a CSV data set config for the > http request for two variables in it. So essentially the CSV has a static > list of values that is looped through but the counter should keep going up > independently of that and just tags those values. > > My test hierarchy looks as such: > > Test plan > |- Thread Group > |- Http Request > |-Simple Data Writer > |- BeanShell Sampler > |- User Defined Variables > > Hopefully that is clear enough, if not, let me know I can provide any > additional details/samples. > > Thanks! > > -- > Joshua Abts >

