class Main{ public static void main(String[] args){ // Demonstrere finally // try{ // System.out.println("Hei"); // return; // } // finally{ // System.out.println("Hadet"); // } // Traader TallBeholder beholder = new TallBeholder(0); int antallTraader = 2; Thread[] plussTraader =new Thread[antallTraader]; Thread[] minusTraader =new Thread[1]; for (int i = 0; i < antallTraader; i++){ plussTraader[i] = new Thread(new Plusser(beholder)); plussTraader[i].start(); } for (int i = 0; i < 1; i++){ minusTraader[i] = new Thread(new Minuser(beholder)); minusTraader[i].start(); } try{ for (Thread traad : plussTraader){ traad.join(); } } catch (InterruptedException e){ //blabla } try{ for (Thread traad : minusTraader){ traad.join(); } } catch (InterruptedException e){ //blabla } System.out.println("Beholder innholder tallet " + beholder.tall); } }