Forum Discussion
M_McDonald
16 years agoSuper Contributor
OK this seems to work:
But what are the risks of this approach? Also, it would be nice, if all the required threads did not reach the script, that all the remaining threads would wake up at the same time.
def testRunnerContext = context.getProperty("LoadTestRunner").context
def threadPool = testRunnerContext.getProperty("threadPool")
def currentThread = Thread.currentThread()
log.info "Thread " + currentThread.id + " starting, threadPool size = " + threadPool.size
if (threadPool.size() >= 4) {
threadPool.each { thread ->
thread.interrupt()
}
} else {
synchronized( this ) {
threadPool.add(currentThread)
}
log.info threadPool.size
try {
currentThread.sleep(10000);
}
catch (InterruptedException ie) {
currentThread.interrupt()
log.info "Thread " + currentThread.id + " interrupted."
}
}
log.info "Thread " + Thread.currentThread().id + " finished."But what are the risks of this approach? Also, it would be nice, if all the required threads did not reach the script, that all the remaining threads would wake up at the same time.