Hello
I am deepening my understanding of the c# language and trying to really understand all the little details.
I have the following code in wish i cannot understand the difference in using t.Join() .
Can anyone help me ?
- using System;
- using System.Threading;
-
- namespace _70483
- {
- public static class Program
- {
- public static void ThreadMethod()
- {
- for (int i = 0; i<10; i++)
- {
- Console.WriteLine("ThreadProc: {0}", i);
- Thread.Sleep(0);
- }
- }
- static void Main(string[] args)
- {
- Thread t = new Thread(new ThreadStart (ThreadMethod));
- t.Start();
-
- for (int i = 0; i< 4 ; i++)
- {
- Console.WriteLine("Main thread: Do some work.");
- Thread.Sleep(0);
- }
- t.Join();
- Console.ReadLine();
- }
-
- }
- }
I have tryed to remove it and cannot see any difference.
Is it maybe because i have Thread.Sleep(0) ?
Best regards
Rui