import java.util.concurrent.CyclicBarrier; import java.util.concurrent.BrokenBarrierException; import java.util.concurrent.CountDownLatch; import java.util.Random; class SiHei implements Runnable{ CyclicBarrier barriere; int speed; int nr; SiHei(CyclicBarrier b, int speed, int nr){ this.speed = speed; this.nr = nr; barriere = b; } public void run() { for (int i =0; i<4; i++){ try { Thread.currentThread().sleep(speed); } catch(Exception e) { System.out.println(e); } System.out.println("hei fra traad nr " + nr + "..."); try { barriere.await(); } catch(InterruptedException e) { System.out.println(e); } catch (BrokenBarrierException e){ System.out.println(e); } } } } class Loper implements Runnable{ Random r; CountDownLatch maal; int lopsNummer; int etapper; Loper(Random r, int etapper, int lopsNummer, CountDownLatch maal){ this.r = r; this.etapper = etapper; this.lopsNummer = lopsNummer; this.maal = maal; } public void run(){ int lopt = 0; int etappeTid; int totalTid = 0; while (lopt