ParallelTask[] runningParallelTasks;
private int doParallelTasks() throws Exception {
final TaskStats stats = getRunData().getPoints().getCurrentStats();
initTasksArray();
ParallelTask t[] = runningParallelTasks = new ParallelTask[repetitions * tasks.size()];
// prepare threads
int index = 0;
for (int k=0; k<repetitions; k++) {
for (int i = 0; i < tasksArray.length; i++) {
final PerfTask task = (PerfTask) tasksArray[i].clone();
t[index++] = new ParallelTask(task);
}
}
// run threads
startThreads(t);
// wait for all threads to complete
int count = 0;
for (int i = 0; i < t.length; i++) {
t[i].join();
count += t[i].count;
if (t[i].task instanceof TaskSequence) {
TaskSequence sub = (TaskSequence) t[i].task;
if (sub.countsByTime != null) {
if (countsByTime == null) {
countsByTime = new int[sub.countsByTime.length];
} else if (countsByTime.length < sub.countsByTime.length) {
countsByTime = ArrayUtil.grow(countsByTime, sub.countsByTime.length);
}
for(int j=0;j<sub.countsByTime.length;j++) {
countsByTime[j] += sub.countsByTime[j];
}
}
}
}
if (countsByTime != null) {
stats.setCountsByTime(countsByTime, logByTimeMsec);
}
// return total count
return count;
}