470e98f9d4054649ef83abff15ae569c549356dc
[lttng-ust-java-tests.git] / src / org / lttng / ust / tests / Runner.java
1 package org.lttng.ust.tests;
2
3 import java.io.IOException;
4 import java.util.LinkedList;
5 import java.util.List;
6 import java.util.logging.Logger;
7
8 public class Runner implements Runnable {
9
10 private final List<Worker> workers;
11 private final List<Thread> workerThreads;
12
13 public Runner(int nbThreads, int nbIter, Logger log)
14 throws SecurityException, IOException {
15 Worker curWorker;
16
17 this.workers = new LinkedList<>();
18 this.workerThreads = new LinkedList<>();
19
20 for (int id = 0; id < nbThreads; id++) {
21 curWorker = new Worker(id, nbIter, log);
22 workers.add(curWorker);
23 workerThreads.add(new Thread(curWorker, "worker " + id));
24 }
25 }
26
27 @Override
28 public void run() {
29 // System.out.println("Starting");
30 for (Thread curThread : workerThreads) {
31 curThread.start();
32 }
33
34 for (Thread curThread : workerThreads) {
35 try {
36 curThread.join();
37 } catch (InterruptedException e) {
38 e.printStackTrace();
39 }
40 }
41 // System.out.println("Finished");
42 }
43 }
This page took 0.03966 seconds and 3 git commands to generate.