Ejemplo n.º 1
0
        public void ExpChessResult_ExitCode_ChessRace()
        {
            ParallelTasks ptasks  = new ParallelTasks();
            int           balance = 0;

            ptasks.Add("t1", () => {
                balance++;
                int dud = balance;
            });
            ptasks.Add("t2", () => {
                balance--;
                int dud = balance;
            });

            ptasks.Execute();
        }
Ejemplo n.º 2
0
        public void SimpleRace()
        {
            ParallelTasks ptasks  = new ParallelTasks();
            int           balance = 0;

            ptasks.Add("t1", () => {
                balance++;
                int dud = balance;
            });
            ptasks.Add("t2", () => {
                balance--;
                int dud = balance;
            });

            ptasks.Execute();
        }
Ejemplo n.º 3
0
        public void ExpChessResult_ExitCode_ChessDeadlock()
        {
            ParallelTasks ptasks = new ParallelTasks();
            object        sync1  = new object();
            object        sync2  = new object();

            ptasks.Add("t1", () => {
                lock (sync1)
                    lock (sync2)
                    { }
            });
            ptasks.Add("t2", () => {
                lock (sync2)
                    lock (sync1)
                    { }
            });

            ptasks.Execute();
        }