1/**
2 * Copyright(C) 1998
3 * All Rights Reserved. Salih Yurttas, ZCubes, BitsOfCode Software Systems, Inc..
4 *
5 * Permission to use, copy, modify, and distribute this
6 * software and its documentation for EDUCATIONAL purposes
7 * and without fee is hereby granted provided that this
8 * copyright notice appears in all copies.
9 *
10 * @date : January 1, 1998.
11 * @authorĀ : Salih Yurttas.
12 */
13
14
15public class DP01 {
16
17 public static void main(String[] argv){
18 int size = 5;
19 Fork[] forks = new Fork[size];
20
21 for(int i=0; i<size; ++i)
22 forks[i] = new Fork();
23
24 for(int i=0; i<size; ++i ) {
25 Fork a = forks[i];
26 Fork b = forks[(i+1)%size];
27 Philosopher p;
28
29 if(i%2==0)
30 p = new Philosopher(i,
31 a,
32 b);
33 else
34 p = new Philosopher(i,
35 b,
36 a);
37 new Thread(p).start();
38 }
39 }
40
41}