import java.util.concurrent.Semaphore; public class Main { static Semaphore elementy = new Semaphore(0); static Semaphore miejsca = new Semaphore(400); public static void main(String[] args) throws InterruptedException { int m = 4; int n = 5; int powt1 = 100; int powt2 = 80; Bufor buff = new Bufor(m*powt1, elementy, miejsca); Producent[] P = new Producent[m]; Konsument[] K = new Konsument[n]; for (int i = 0; i < 4; i++) { P[i] = new Producent("P - " + i, buff, powt1); P[i].start(); } for (int i = 0; i < 5; i++) { K[i] = new Konsument("K - " + i, buff, powt2); K[i].start(); } for (int i = 0; i < m; i++) { P[i].join(); } for (int i = 0; i < n; i++) { K[i].join(); } System.out.println("KONIEC PROGRAMU"); } }