ConditionDemo: Using Condition locks

This commit is contained in:
Karsten Jeppesen
2021-03-02 19:53:52 +01:00
parent ba6d58efb9
commit db15919928
7 changed files with 258 additions and 0 deletions

View 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();
}
}