19 lines
277 B
Plaintext
19 lines
277 B
Plaintext
monitor s{
|
|
condition c;
|
|
int elem;
|
|
void pushElement(int val){
|
|
elem = val;
|
|
signalc(c);
|
|
}
|
|
int getElement(){
|
|
waitc(c);
|
|
return elem;
|
|
}
|
|
init { elem = 0; }
|
|
}
|
|
void prod() { pushElement(10); }
|
|
void kons() { cout << getElement(); }
|
|
main(){
|
|
cobegin { prod(); kons(); };
|
|
}
|