Facebook
From d, 1 Year ago, written in Java.
Embed
Download Paste or View Raw
Hits: 96
  1. public class EatingPhilosophersProblem {
  2.     public static void main(String[] args) {
  3.         Philosopher[] philosophers = new Philosopher[5];
  4.         for (int i = 0; i < philosophers.length; i++) {
  5.             philosophers[i] = new Philosopher();
  6.              
  7.             Thread t = new Thread(philosophers[i], "Philosopher " + (i + 1));
  8.             t.start();
  9.         }
  10.     }
  11. }