dbrown
Class Restaurant

java.lang.Object
  extended by dbrown.Restaurant
All Implemented Interfaces:
java.lang.Runnable

public class Restaurant
extends java.lang.Object
implements java.lang.Runnable

Version:
2005-11-09 Main class for the Restaurant simulation. Spawns one Chef, multiple waiters, and their viewers, and passes one order at a time between the Chef and Waiters.
Author:
David B. Brown from Bruce Eckel

Field Summary
private  Chef chef
          The Restaurant's Chef object.
private  boolean closed
          Tracks whether the restaurant is closed or not.
private  Order order
          Restaurant owns and creates the original Orders, and controls their sharing between chef and waiter.
private  java.lang.Thread t
          The Restaurant thread.
(package private)  Waiter[] waiters
          The Waiters.
static int WAITERS
          Number of waiters in restaurant.
 
Constructor Summary
Restaurant()
          Restaurant constructor.
 
Method Summary
 boolean getClosed()
          Returns whether the restaurant is closed or not.
static void main(java.lang.String[] args)
          Test the threading program.
 void run()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

WAITERS

public static final int WAITERS
Number of waiters in restaurant.

See Also:
Constant Field Values

chef

private Chef chef
The Restaurant's Chef object.


closed

private boolean closed
Tracks whether the restaurant is closed or not.


order

private Order order
Restaurant owns and creates the original Orders, and controls their sharing between chef and waiter.


t

private java.lang.Thread t
The Restaurant thread.


waiters

Waiter[] waiters
The Waiters.

Constructor Detail

Restaurant

public Restaurant()
Restaurant constructor. Creates the Chef and Waiter objects and their respective viewers. Starts the Restaurant thread.

Method Detail

main

public static void main(java.lang.String[] args)
Test the threading program.

Parameters:
args - Unused.

getClosed

public boolean getClosed()
Returns whether the restaurant is closed or not.

Returns:
whether the restaurant is closed.

run

public void run()
Specified by:
run in interface java.lang.Runnable