ConditionDemo: Using Condition locks
This commit is contained in:
22
ConditionDemo/src/ConditionDemo.java
Normal file
22
ConditionDemo/src/ConditionDemo.java
Normal file
@@ -0,0 +1,22 @@
|
||||
// Running the world
|
||||
//
|
||||
|
||||
public class ConditionDemo {
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
SharedFiFoQueue sharedQueue = new SharedFiFoQueue(10);
|
||||
|
||||
//Create a producer and a consumer.
|
||||
Thread producer = new Producer(sharedQueue);
|
||||
Thread consumer = new Consumer(sharedQueue);
|
||||
|
||||
//Start both threads.
|
||||
producer.start();
|
||||
consumer.start();
|
||||
|
||||
//Wait for both threads to terminate.
|
||||
producer.join();
|
||||
consumer.join();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user