monitor prod_kons { int produkt; int nowys; condition nowy, uzyty; void dodaj_element(int pr){ if(nowys==1) waitc(uzyty); produkt=pr; nowys=1; signalc(nowy); } int pobierz_element(){ if(!nowys) waitc(nowy); nowys=0; signalc(uzyty); return produkt; } init { nowys = 0; } } void producent(){ int i; for(i=0;i<50;i++){ dodaj_element(i); } } void konsument(){ int i; for(i=0;i<50;i++){ cout << pobierz_element() << endl;; } } main(){ cobegin{ producent(); konsument(); } }