import java.util.concurrent.CountDownLatch; public class Main { public static void main(String[] args) { final int ANTALL_TRAADER = 10; Monitor monitor = new Monitor(); CountDownLatch latch = new CountDownLatch(ANTALL_TRAADER); Runnable task = new MyTask(monitor, latch); for (int i = 0; i < ANTALL_TRAADER; i++) { new Thread(task).start(); } try { latch.await(); } catch (InterruptedException e) { System.out.println("Avbrutt..."); System.exit(-1); } System.out.println("Alle traader er ferdige! Counter-en er naa: " + monitor.getCounter()); } }