ctx.getThreadNum() returns a 0-based thread number, the variable __threadNum is 1-based Reproducible in JMeter 4 and 5 with a simple test plan: a thread group, a constant throughput timer a JSR223 sampler which just logs log.info("from ctx:"+ctx.getThreadNum()) log.info("from variable: ${__threadNum}") in jmeter.log I see for example for the first thread 2018-09-18 22:45:07,610 INFO o.a.j.t.JMeterThread: Thread started: Thread Group 1-1 ... 2018-09-18 22:45:08,085 INFO o.a.j.p.j.s.JSR223Sampler: from ctx:0 2018-09-18 22:45:08,085 INFO o.a.j.p.j.s.JSR223Sampler: from variable: 1 It's probably late to change this without potentially breaking backward compatibility, so a documentation update can be used to clarify this small inconsistency Documentation for ctx.getThreadNum http://jmeter.apache.org/api/org/apache/jmeter/threads/JMeterThread.html#getThreadNum-- Documentation for the JMeter variables http://jmeter.apache.org/usermanual/functions.html#__threadNum
Author: pmouawad Date: Sat Nov 3 22:47:02 2018 New Revision: 1845700 URL: http://svn.apache.org/viewvc?rev=1845700&view=rev Log: Bug 62752 - Add to Documentation: ctx.getThreadNum() 0-based and ${__threadNum} 1-based Bugzilla Id: 62752 Modified: jmeter/trunk/src/core/org/apache/jmeter/threads/JMeterContext.java jmeter/trunk/xdocs/changes.xml jmeter/trunk/xdocs/usermanual/functions.xml
Date: Sun Nov 4 11:37:54 2018 New Revision: 1845725 URL: http://svn.apache.org/viewvc?rev=1845725&view=rev Log: Add location of JMeterContext API to link and write out numbers as words Follow-up to r1845700 Bug 62752 - Add to Documentation: ctx.getThreadNum() 0-based and ${__threadNum} 1-based Bugzilla Id: 62752
This issue has been migrated to GitHub: https://github.com/apache/jmeter/issues/4870