Reputation: 563
I'm extending AbstractJavaSamplerClient and creating a custom Java Sampler. It's all working good but I wonder if is there a way to get current thread number(or a name, something unique to the thread) and number of all threads running my custom sampler.
I have a 'Thread Group' and a 'Java Request' running my custom java sampler client. For instance I'm setting 'Number of Threads' to 5. I need to access the current thread's number and the number of all threads (5 in this case) in my custom java sampler.
Is there a common way to do it?
thanks in advance. aykut
Upvotes: 3
Views: 1714
Reputation: 22948
Yes there is such property in Jmeter. If for instance you'd like to add names to your threads including their number(and save it to property) it would be something like this:
${__setProperty(ThreadName,${__javaScript("HttpThread_" + ${__threadNum},)},)}
Then you can read this by using :
${__property(ThreadName,,)}
Or thread id standalone, this will be always unique ${__threadNum}
This is the answer if you were asking how to get that property in jmeter, and NOT in your custom sample java code.
Upvotes: 2