import java.util.concurrent.CountDownLatch; public class TestCountdown { public static void main(String[] args) throws InterruptedException{ int antTraader = 5; CountDownLatch ferdigSignal = new CountDownLatch(antTraader); Monitor monitor = new Monitor(); for (int i = 0; i < antTraader; i++) { new Thread(new Task(ferdigSignal, monitor)).start(); } ferdigSignal.await(); System.out.println("Alle traader har fullf?rt! Antall: " + monitor.hentTeller()); } }