Click here to Skip to main content
15,886,518 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Thread t = new Thread(Method1);
t.Start(); 
Thread.Sleep(2000); 
t.Join();
Thread t1 = new Thread(Method2); 
t1.Start(); 
Thread.Sleep(2000); 
t1.Join();
Thread t2 = new Thread(Method3); 
t2.Start();
How Thread.Sleep()  makes each thread wait? How is it associated with each thread?
Posted

1 solution

It does not. Only the main thread is paused because it is called from the main thread. It will only pause the thread if you call it from the actual thread method. Something like this:
Thread t = new Thread(Work);
t.Start();

public static void Work(object data) 
{
  Thread.Sleep(1000);
}

Good luck!
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900