public DiningPhilosophersForm()
        {
            InitializeComponent();

            for (int i = 0; i < NR; i++)
            {
                sticks[i] = new Sticks(1, 1);
            }

            for (int i = 0; i < NR; i++)
            {
                phils[i] = new Philosopher(sticks[i], sticks[(i + NR - 1) % NR], this);
                Thread t = new Thread(phils[i].Run);
                t.IsBackground = true;
                t.Start();
            }

            colors[0] = Color.Green;
            colors[1] = Color.Red;
            colors[2] = Color.Blue;
            colors[3] = Color.Yellow;
            colors[4] = Color.Magenta;
            //colors[5] = Color.Cyan;
            //colors[6] = Color.Pink;
        }
Esempio n. 2
0
 public Philosopher(Sticks obj, Form form)
 {
     this.percentageTakenLeft  = 0;
     this.percentageTakenRight = 0;
     this.rightStick           = right;
     this.leftStick            = left;
     this.form = form;
 }
Esempio n. 3
0
 internal static void PulseAll(Sticks sticks)
 {
     throw new NotImplementedException();
 }
Esempio n. 4
0
 internal static void Wait(Sticks sticks)
 {
     throw new NotImplementedException();
 }
Esempio n. 5
0
 internal static void Pulse(Sticks obj)
 {
     throw new NotImplementedException();
 }