University of Engineering and Management Kolkata Operating System Project Project Report Submitted by
University of Engineering and Management Kolkata Operating System Project Project Report Submitted by
KOLKATA
____________________
Signature of Examiner
ACKNOWLEDGEMENT
SOFTWARE USED
Here we have used Java to Code the program using Javac Compiler.
THEORY
SOURCE CODE
class X{
int i;
boolean printed=false; // Start be printing the given number
boolean incremented=true; // Just to allow printing to start first
X(int i){
this.i=i;
}
System.out.println("ex");
}
}
i++;
incremented=true;
printed=false;
notifyAll();
}
synchronized void print(){
while(printed){
try {
wait();
}
catch (InterruptedException e){
System.out.println("ext");
}
}
System.out.println(i);
printed=true;
incremented=false;
notifyAll();
}
}
T1(X a){
this.a=a;
}
T2(X a){
this.a=a;
}
}
public class os_pro {
public static void main(String[] args){
X a = new X(0);
T1 thread1 = new T1(a);
T2 thread2 = new T2(a);
thread1.start();
thread2.start();
try {
thread1.join();
thread2.join();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
OUTPUT
CONCLUSION
BIBLIOGRAPHY
https://www.quora.com
https://en.wikipedia.org/wiki/Synchronization_(computer_science)