static void ThreadMethod() { Debug.WriteLine("Thread a " + Thread.CurrentThread.ManagedThreadId + " has control"); for(int i=0;i<10000;i++){ Debug.Write("x"); } } private void runTest(object sender, EventArgs e) { new Thread(new ThreadStart(ThreadMethod)).Start(); Debug.WriteLine("Thread b " + Thread.CurrentThread.ManagedThreadId + " has control"); for (int i = 0; i < 10000; i++) { Debug.Write("y"); } }
Threadb 1856968798 has control yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy....yyy Threada -305810110 has control xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...xxx