package diningphilosophers3;

import java.util.Timer;

/**
 * @author  Ralf Kunze (rkunze@uos.de), Institut fuer Informatik, Universitaet Osnabrueck
 * @date 10.05.2007
 */
public class EssTisch {

	public static void main(String[] args) {
		final int PHILOSOPHERS = 5;
		ChopStick[] forks = new ChopStick[PHILOSOPHERS];
		Philosopher[] philosophers = new Philosopher[PHILOSOPHERS];
		
		for(int i = 0; i<PHILOSOPHERS; i++) {
			forks[i] = new ChopStick("Fork"+i);
		}
		
		for(int i = 0; i<PHILOSOPHERS; i++) {
			philosophers[i] = new Philosopher(i,forks[i],forks[(i+1)%PHILOSOPHERS]);
			philosophers[i].start();
		}
		
		Timer timer = new Timer();
		timer.schedule(new PrintPhilosophersInformation(philosophers),2000,2000);
//		for(int i = 0; i<PHILOSOPHERS; i++) {
//			System.out.print(philosophers[i]+"  |  ");
//		}
	}

}
