/** * A philosopher who thinks and eats with two forks. * * @author Franck van Breugel */ public class Philosopher extends Thread { private int id; private 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; } /** * This philosopher's life. */ public void run() { while (true) { // think this.table.pickUp(id); this.table.pickUp(id + 1); // eat this.table.putDown(id); this.table.putDown(id + 1);} } } }