Threads
Application
Classes
The Order class
Constructor | Description |
Order(int number) | Creates an Order object with the specified number. |
Method | Description
|
toString() | Returns a string in the form "Order #n," where n is the order number. |
The OrderQueue class
Method | Description |
pushOrder(String order) | Adds the specified order to the queue. For simplicity, the order is a String value. |
String pullOrder() | Retrieves the first available order from the queue. |
The OrderTaker class
Constructor | Description |
OrderTaker(int orderCount, OrderQueue queue) | Creates a new order taker that adds the specified number of orders to the queue. |
Method | Description
|
run() | Adds the number of orders specified by the constructor to the queue specified by the constructor, sleeping for one second between orders. |
The OrderHandler class
Constructor | Description |
OrderHandler(OrderQueue queue) | Creates a new order handler that reads orders from the specified queue. |
Method | Description
|
run() | Retrieves orders from the queue specified by the constructor. A message is displayed on the console for each order retrieved, and the thread sleeps for two seconds between orders. |