You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by pm...@apache.org on 2015/12/08 23:08:32 UTC
svn commit: r1718723 -
/jmeter/trunk/src/core/org/apache/jmeter/threads/ThreadGroup.java
Author: pmouawad
Date: Tue Dec 8 22:08:32 2015
New Revision: 1718723
URL: http://svn.apache.org/viewvc?rev=1718723&view=rev
Log:
#resolve #49
Modified:
jmeter/trunk/src/core/org/apache/jmeter/threads/ThreadGroup.java
Modified: jmeter/trunk/src/core/org/apache/jmeter/threads/ThreadGroup.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/threads/ThreadGroup.java?rev=1718723&r1=1718722&r2=1718723&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/threads/ThreadGroup.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/threads/ThreadGroup.java Tue Dec 8 22:08:32 2015
@@ -267,7 +267,7 @@ public class ThreadGroup extends Abstrac
@Override
public void start(int groupCount, ListenerNotifier notifier, ListedHashTree threadGroupTree, StandardJMeterEngine engine) {
running = true;
- int numThreads = getNumThreads();
+ int numThreads = getNumThreads();
int rampUp = getRampUp();
float perThreadDelay = ((float) (rampUp * 1000) / (float) getNumThreads());
@@ -342,22 +342,30 @@ public class ThreadGroup extends Abstrac
*/
@Override
public boolean stopThread(String threadName, boolean now) {
- for(Entry<JMeterThread, Thread> entry : allThreads.entrySet()){
+ for(Entry<JMeterThread, Thread> entry : allThreads.entrySet()) {
JMeterThread thrd = entry.getKey();
- if (thrd.getThreadName().equals(threadName)){
- thrd.stop();
- thrd.interrupt();
- if (now) {
- Thread t = entry.getValue();
- if (t != null) {
- t.interrupt();
- }
- }
+ if (thrd.getThreadName().equals(threadName)) {
+ stopThread(thrd, entry.getValue(), now);
return true;
}
}
return false;
}
+
+ /**
+ * @param thrd JMeterThread
+ * @param t Thread
+ * @param interrupt Interrup thread or not
+ */
+ private void stopThread(JMeterThread thrd, Thread t, boolean interrupt) {
+ thrd.stop();
+ thrd.interrupt(); // interrupt sampler if possible
+ if (interrupt) {
+ if (t != null) { // Bug 49734
+ t.interrupt(); // also interrupt JVM thread
+ }
+ }
+ }
/**
* Called by JMeterThread when it finishes
@@ -384,16 +392,11 @@ public class ThreadGroup extends Abstrac
threadStarter.interrupt();
} catch (Exception e) {
log.warn("Exception occured interrupting ThreadStarter");
- }
+ }
}
+
for (Entry<JMeterThread, Thread> entry : allThreads.entrySet()) {
- JMeterThread item = entry.getKey();
- item.stop(); // set stop flag
- item.interrupt(); // interrupt sampler if possible
- Thread t = entry.getValue();
- if (t != null ) { // Bug 49734
- t.interrupt(); // also interrupt JVM thread
- }
+ stopThread(entry.getKey(), entry.getValue(), true);
}
}
@@ -433,7 +436,7 @@ public class ThreadGroup extends Abstrac
@Override
public boolean verifyThreadsStopped() {
boolean stoppedAll = true;
- if (delayedStartup){
+ if (delayedStartup) {
stoppedAll = verifyThreadStopped(threadStarter);
}
for (Thread t : allThreads.values()) {
@@ -470,7 +473,7 @@ public class ThreadGroup extends Abstrac
@Override
public void waitThreadsStopped() {
if (delayedStartup) {
- waitThreadStopped(threadStarter);
+ waitThreadStopped(threadStarter);
}
for (Thread t : allThreads.values()) {
waitThreadStopped(t);