Introduction
The java dynamicthread example is extracted from the most popular open source projects, you can refer to the following example for usage.
Programming language: Java
Class/type: DynamicThread
Example#1File:
AbstractThreadStarter.javaProject:
turnupthesun123/jmeter-plugins
protected DynamicThread addActiveThread() {
DynamicThread threadWorker = makeThread(threadIndex++);
owner.addThread(threadWorker);
Thread thread = new Thread(threadWorker, threadWorker.getThreadName());
threadWorker.setOSThread(thread);
thread.setDaemon(false); // we can't have it daemon, since it will stay and eat RAM in UI mode
thread.start();
treeClone = cloneTree(threadGroupTree); // use background time to clone tree
return threadWorker;
}
Example#2File:
AbstractThreadStarter.javaProject:
turnupthesun123/jmeter-plugins
protected DynamicThread makeThread(long threadIndex) {
boolean onErrorStopTest = owner.getOnErrorStopTest();
boolean onErrorStopTestNow = owner.getOnErrorStopTestNow();
boolean onErrorStopThread = owner.getOnErrorStopThread();
boolean onErrorStartNextLoop = owner.getOnErrorStartNextLoop();
final DynamicThread jmeterThread = new DynamicThread(treeClone, this.owner, notifier);
jmeterThread.setThreadNum((int) threadIndex);
jmeterThread.setThreadGroup(this.owner);
jmeterThread.setInitialContext(context);
final String threadName = owner.getName() + " " + groupIndex + "-" + (threadIndex + 1);
jmeterThread.setThreadName(threadName);
jmeterThread.setEngine(engine);
jmeterThread.setOnErrorStopTest(onErrorStopTest);
jmeterThread.setOnErrorStopTestNow(onErrorStopTestNow);
jmeterThread.setOnErrorStopThread(onErrorStopThread);
jmeterThread.setOnErrorStartNextLoop(onErrorStartNextLoop);
return jmeterThread;
}