public class Barrier { public static void main(String[] args) { Thread[] threads = new Thread[10]; for(int i = 0; i < threads.length; i++) { threads[i] = new Thread(new Worker()); threads[i].start(); } for(Thread t: threads) { try { t.join(); } catch(InterruptedException e) { System.exit(1); } } System.out.println("Systemet avslutter"); } } class Worker implements Runnable { public void run() { System.out.println("hei"); } }