You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
omp-ha-2019/src/main/java/_11/_2/alternative/NumberRunner.java

28 lines
591 B
Java

package _11._2.alternative;
public class NumberRunner extends Thread {
private static final Checkpoint CHECKPOINT = new Checkpoint(Barriers.NUMBER_OF_RUNNERS);
private final int id;
public NumberRunner(int id) {
this.id = id;
}
@Override
public void run() {
for(int i = 0; i < 1000; i++) {
if(i % 10 == 0) {
try {
CHECKPOINT.gather();
} catch(InterruptedException e) {
throw new IllegalStateException("Group can never be complete again, because one of the members got lost", e);
}
}
System.out.println("Thread " + this.id + ": " + i);
}
}
}