import java.util.Scanner; import java.util.concurrent.CountDownLatch; class Main{ public static void main(String[] args){ // Oppretter monitoren (som inneholder Mat-beholder) MatMonitor monitor = new MatMonitor(); // Opprett l?venavn String[] navneliste = {"Mufasa", "Scar", "Simba", "Nala"}; int antallLoever = navneliste.length; // CountDownLatch CountDownLatch counter = new CountDownLatch(antallLoever); // Oppretter tr?dene // UFERDIG // Loeve[] loeveliste = new Loeve[antallLoever]; Thread[] loeveTraader = new Thread[antallLoever]; for (int i = 0; i < antallLoever; i++){ loeveliste[i] = new Loeve(navneliste[i], monitor, counter); loeveTraader[i] = new Thread(loeveliste[i]); loeveTraader[i].start(); } // Lage mattraad Thread mattraad = new Thread(new Matprodusent(monitor)); mattraad.start(); Thread oppdaterTraad = new Thread(new Oppdaterer(loeveliste, monitor)); oppdaterTraad.start(); // Venter p? at du skal trykke enter for ? avslutte programmet // System.out.println("Trykk enter for aa avslutte programmet"); // Scanner scanner = new Scanner(System.in); // String inp = scanner.nextLine(); // monitor.settFerdig(); try{ counter.await(); } catch (InterruptedException e){ // } monitor.settFerdig(); System.out.println("Alle loevene er doede"); } }