import java.util.ArrayList; public class MainKaffe { public static void main(String[] args) throws InterruptedException { ArrayList traader = new ArrayList<>(); int antDrikkere = 5; int antBaristaer = 10; ArrayList baristaer = new ArrayList<>(); Bord bord = new Bord(antBaristaer); for(int i = 0; i < antBaristaer; i++){ Barista barista = new Barista(bord, i, antBaristaer); Thread traad = new Thread(barista); traader.add(traad); baristaer.add(barista); traad.start(); } for(int i = 0; i < antDrikkere; i++){ Kaffedrikker drikker = null; if(i % 2 == 0){ drikker = new Kaffedrikker(bord, baristaer.get(0)); } else { drikker = new Kaffedrikker(bord, baristaer.get(1)); } Thread traad = new Thread(drikker); traader.add(traad); traad.start(); } for(Thread traad : traader){ traad.join(); } } }