Separating into Tech and SysDev
This commit is contained in:
28
Technology/MonitorCase1/src/PC.java
Normal file
28
Technology/MonitorCase1/src/PC.java
Normal file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Run this code.
|
||||
* 1: What happens ?
|
||||
* 2: Why does it happen ?
|
||||
*
|
||||
* Code courtesy of www.csc.villanova.edu/~mdamian/threads/javamonitors.html
|
||||
*/
|
||||
public class PC {
|
||||
|
||||
public static void main(String[] args) {
|
||||
Buffer b = new Buffer(4);
|
||||
Producer p = new Producer(b);
|
||||
Consumer c = new Consumer(b);
|
||||
|
||||
p.start();
|
||||
c.start();
|
||||
|
||||
try {
|
||||
p.join();
|
||||
c.join();
|
||||
} catch (InterruptedException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
System.out.println("End");
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user