public void think() { print("[Philosopher " + position + "] is thinking"); try { Thread.sleep(rnd.nextInt(maxTimeout)); } catch (InterruptedException e) { e.printStackTrace(); } print("[Philosopher " + position + "] is hungry"); startWait = System.currentTimeMillis(); }
public void eat() { waitTime += System.currentTimeMillis() - startWait; print("[Philosopher " + position + "] is eating"); try { Thread.sleep(rnd.nextInt(maxTimeout)); } catch (InterruptedException e) { e.printStackTrace(); } eatCount++; print("[Philosopher " + position + "] finished eating"); }