示例#1
0
        public static void Main(String[] args)
        {
            Console.WriteLine("Please input the thread number:\t");
            int Tnumber = Convert.ToInt32(Console.ReadLine());

            Console.WriteLine(Tnumber);

            RWTask t = new RWTask();

            string[] s = new string[] { "write", "read", "write", "read", "write" };

            Thread[] tlist = new Thread[Tnumber];
            //Console.WriteLine("{0}", s[0]);
            Random ro = new Random();

            int rwtype = 0;

            for (int i = 0; i < Tnumber; i++)
            {
                rwtype = ro.Next(5);
                Thread t1 = new Thread(t.action);
                Console.WriteLine("new Thread:{0},type:{1}", t1.ManagedThreadId, rwtype);
                tlist[i] = t1;
                t1.Start(s[rwtype]);
            }
            for (int j = 0; j < Tnumber; j++)
            {
                tlist[j].Join();
            }
            Console.WriteLine("End");
            Console.ReadKey();
        }
示例#2
0
 public void WriteFirstTest(ref RWTask rw)
 {
 }