示例#1
0
        static void Main(string[] args)
        {
            int numTasks = 20;
            var state = new SharedState();
            var tasks = new Thread[numTasks];

            for (int i = 0; i < numTasks; i ++ )
            {
                tasks[i] = new Thread(new Job(state).DoTheJob);
                tasks[i].Start();
            }

            for (int i = 0; i < numTasks; i++)
            {
                tasks[i].Join();
            }
            Console.WriteLine("summarized {0}", state.State);
        }
示例#2
0
 public Job(SharedState sharedState)
 {
     this.sharedState = sharedState;
 }