/** * A philosopher who thinks, sits down, and eats with two forks. * * @author Franck van Breugel */ public class Philosopher extends Thread { protected int id; protected Table table; /** * Initialize this philosopher with the given id and table. * * @param id the id of this philosopher. * @param table the table of this philosopher. */ public Philosopher(int id, Table table) { this.id = id; this.table = table; } /** * Life of this philosopher. */ public void run() { while (true) { // think this.table.sitDown(); this.table.pickUp(this.id); this.table.pickUp(this.id + 1); // eat this.table.putDown(this.id); this.table.putDown(this.id + 1); this.table.standUp(); } } }