You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by se...@apache.org on 2012/08/14 03:21:14 UTC

svn commit: r1372697 - /jmeter/trunk/src/core/org/apache/jmeter/threads/ThreadGroup.java

Author: sebb
Date: Tue Aug 14 01:21:14 2012
New Revision: 1372697

URL: http://svn.apache.org/viewvc?rev=1372697&view=rev
Log:
No need to use AtomicBoolean here.
Also slightly clearer to use running rather than !stopped, so changed name and inverted the value.
Will also be useful if/when JMeterThread instance creation is moved here.

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=1372697&r1=1372696&r2=1372697&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/threads/ThreadGroup.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/threads/ThreadGroup.java Tue Aug 14 01:21:14 2012
@@ -78,9 +78,9 @@ public class ThreadGroup extends Abstrac
     private Map<JMeterThread, Thread> allThreads = new ConcurrentHashMap<JMeterThread, Thread>();
 
     /**
-     * Was test stopped
+     * Is test (still) running?
      */
-    private AtomicBoolean stopped = new AtomicBoolean(false);
+    private volatile boolean running = false;
 
     /**
      * Are we using delayed startup?
@@ -271,7 +271,7 @@ public class ThreadGroup extends Abstrac
             long end = start + delay;
             long now=0;
             long pause = RAMPUP_GRANULARITY;
-            while(!stopped.get() && (now = System.currentTimeMillis()) < end) {
+            while(running && (now = System.currentTimeMillis()) < end) {
                 long togo = end - now;
                 if (togo < pause) {
                     pause = togo;
@@ -290,8 +290,8 @@ public class ThreadGroup extends Abstrac
      */
     @Override
     public void start() {
+        running = true;
         if (delayedStartup) {
-            stopped.set(false);
             this.threadStarter = new Thread(new ThreadStarter(), getName()+"-ThreadStarter");
             threadStarter.start();  
             try {
@@ -374,8 +374,8 @@ public class ThreadGroup extends Abstrac
      */
     @Override
     public void tellThreadsToStop() {
+        running = false;
         if (delayedStartup) {
-            stopped.set(true);
             try {
                 threadStarter.interrupt();
             } catch (Exception e) {
@@ -402,8 +402,8 @@ public class ThreadGroup extends Abstrac
      */
     @Override
     public void stop() {
+        running = false;
         if (delayedStartup) {
-            stopped.set(true);
             try {
                 threadStarter.interrupt();
             } catch (Exception e) {
@@ -517,7 +517,7 @@ public class ThreadGroup extends Abstrac
             }
             for (int i = 0; i < jMeterThreads.length; i++) {
                 try {
-                    if(!stopped.get()) {
+                    if(running) {
                         Thread.sleep(Math.round(perThreadDelay));
                         Thread newThread = new Thread(jMeterThreads[i]);
                         newThread.setName(jMeterThreads[i].getThreadName());