<<< Sample output from the Order Queue application | Index | Order Queue sequence diagram >>> |
Order class:
Constructor creates an Order object with a unique order number
toString() method returns a string in the form "Order #n" where n is the order number
OrderQueue -- a thread-safe method-synchronized class
pushOrder( Order ) method adds order to the queue
Order pullOrder() method retrieves the first available order from the queue
OrderTaker -- a worker thread class
Constructor OrderTaker( int orderCount, OrderQueue queue ) takes specified number of orders to be added to the queue
run() adds orders to the queue and displays info about each order added. The thread sleeps for one second between the orders.
OrderHandler -- a worker thread class
Constructor OrderHandler( OrderQueue queue ) creates the order handler and takes reference to the queue
run() retrieves orders from the queue and displayes info for each order retrieved. The thread sleeps for two seconds between the orders.
<<< Sample output from the Order Queue application | Index | Order Queue sequence diagram >>> |