public static long Problem2(string input) { //input = "snd 1\nsnd 2\nsnd p\nrcv a\nrcv b\nrcv c\nrcv d"; var q0t1 = new Queue <long>(); var q1t0 = new Queue <long>(); var pgm0 = new pgm(input, 0) { Input = q1t0, Output = q0t1 }; var pgm1 = new pgm(input, 1) { Input = q0t1, Output = q1t0 }; while (true) { pgm0.Step(); pgm1.Step(); if (pgm0.terminated && pgm1.terminated) { break; } if (pgm0.waitforinput && pgm1.waitforinput && !q0t1.Any() && !q1t0.Any()) { break; } } return(pgm1.sendcount); }
public static pgm operator*(pgm _obj1, pgm _obj2) { pgm _obj3 = new pgm(0, 0); _obj3.a = _obj1.a * _obj2.a; _obj3.b = _obj1.b * _obj2.b; return(_obj3); }
public static void Main() { Thread newThread = new Thread(pgm.work1); newThread.Start(20); pgm p = new pgm(); newThread = new Thread(p.work2); newThread.Start("Instance"); Console.ReadLine(); }
public static void Main() { pgm a1 = new pgm(1, 2); pgm a2 = new pgm(2, 4); pgm a3 = new pgm(1, 2); a3 = a1 * a2; pgm.show(a3); }
public static void show(pgm _obj) { Console.WriteLine("a=" + _obj.a); Console.WriteLine("b=" + _obj.b); }