Diffrence between thread.sleep and monitor.wait

Posted by Dipu710646 under C# on 11/26/2010 | Points: 10 | Views : 7495 | Status : [Member] | Replies : 2
Hi All,

Can u please tell me what is the difference between thread.sleep and monitor.wait ?




Responses

Posted by: SheoNarayan on: 11/26/2010 [Administrator] HonoraryPlatinum | Points: 25

Up
0
Down
Thread.Sleep pauses the current thread for specified number of milliscond

Thread.Sleep(5000); // sleep for 5000 millisecond


Monitor.Wait releases the lock on an object and blocks the current thread until it reacquires the lock. Look at this http://msdn.microsoft.com/en-us/library/system.threading.monitor.wait.aspx and http://www.albahari.com/threading/part4.aspx for real time example.

Thanks


Regards,
Sheo Narayan
http://www.dotnetfunda.com

Dipu710646, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Gokul on: 12/8/2010 [Member] Starter | Points: 25

Up
0
Down
thread.sleep()

The thread's execution can be paused by calling the thread.sleep(). IT ALWAYS TAKES THE INTEGER VALUE.

Thanks and Regards,
GokulNath Nithy.

Dipu710646, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response