Professional Documents
Culture Documents
Os Lab 5
Os Lab 5
Reg.No: 20bci7097
CODE:
/*
*/
package os.lab.pkg4;
/**
* @author ivanc
*/
import java.util.*;
public class s {
int n = 3;
int v = 0;
synchronized (this) {
while (list.size() == n) {
wait();
list.add(v++);
System.out.println(" Produce " + v + " buffer is " + list);
notify();
Thread.sleep(100);
synchronized (this) {
while (list.size() == 0) {
wait();
notify();
Thread.sleep(100);
throws InterruptedException {
@Override
o.produce();
} catch (InterruptedException e) {
});
@Override
try {
o.produce();
} catch (InterruptedException e) {
});
@Override
try {
o.consume();
} catch (InterruptedException e) {
});
@Override
try {
o.consume();
} catch (InterruptedException e) {
});
t1.start();
t2.start();
t3.start();
t1.join();
t2.join();
t3.join();
OUTPUT