Beispiel #1
0
        public Philosopher(int n, Fork fork)
        {
            N     = n;
            Fork  = fork;
            left  = n == 0 ? 4 : n - 1;
            right = (n + 1) % 5;
            Thread thread = new Thread(new ThreadStart(Run));

            thread.Start();
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            Fork fork = new Fork();

            new Philosopher(0, fork);
            new Philosopher(1, fork);
            new Philosopher(2, fork);
            new Philosopher(3, fork);
            new Philosopher(4, fork);
        }