/** * A room containing a table for philosophers. * * @author Franck * */ public class Room { private int number; /** * Initializes this room to be empty. */ public Room() { this.number = 0; } /** * A philosopher enters this room. */ public synchronized void enter() { while (this.number == Table.SIZE - 1) { try { this.wait(); } catch (InterruptedException e) { e.printStackTrace(); } } this.number++; } /** * A philosopher leaves this room. */ public synchronized void leave() { this.number--; this.notifyAll(); } }