git-svn-id: https://svn.apache.org/repos/asf/jmeter/trunk@1372950 13f79535-47bb-0310-9956-ffa450edef68

Former-commit-id: 31f9a1b3d1
This commit is contained in:
Sebastian Bazley 2012-08-14 15:58:34 +00:00
parent ae0c13a2bf
commit b79040c012
1 changed files with 24 additions and 35 deletions

View File

@ -222,43 +222,32 @@ public class ThreadGroup extends AbstractThreadGroup {
float perThreadDelay = ((float) (rampUp * 1000) / (float) getNumThreads());
thread.setInitialDelay((int) (perThreadDelay * thread.getThreadNum()));
}
scheduleThread(thread, this);
// if true the Scheduler is enabled
if (getScheduler()) {
long now = System.currentTimeMillis();
// set the start time for the Thread
if (getDelay() > 0) {// Duration is in seconds
thread.setStartTime(getDelay() * 1000 + now);
} else {
long start = getStartTime();
if (start < now) {
start = now; // Force a sensible start time
}
thread.setStartTime(start);
}
// set the endtime for the Thread
if (getDuration() > 0) {// Duration is in seconds
thread.setEndTime(getDuration() * 1000 + (thread.getStartTime()));
} else {
thread.setEndTime(getEndTime());
}
// Enables the scheduler
thread.setScheduled(true);
}
}
/**
* This will schedule the time for the JMeterThread.
*
* @param thread JMeterThread
* @param group ThreadGroup
*/
private void scheduleThread(JMeterThread thread, ThreadGroup group) {
// if true the Scheduler is enabled
if (group.getScheduler()) {
long now = System.currentTimeMillis();
// set the start time for the Thread
if (group.getDelay() > 0) {// Duration is in seconds
thread.setStartTime(group.getDelay() * 1000 + now);
} else {
long start = group.getStartTime();
if (start < now) {
start = now; // Force a sensible start time
}
thread.setStartTime(start);
}
// set the endtime for the Thread
if (group.getDuration() > 0) {// Duration is in seconds
thread.setEndTime(group.getDuration() * 1000 + (thread.getStartTime()));
} else {
thread.setEndTime(group.getEndTime());
}
// Enables the scheduler
thread.setScheduled(true);
}
}
/**
* Wait for delay with RAMPUP_GRANULARITY
* @param delay delay in ms