What is the use of Monitor in C#?
Interview question and answer by:
Raja | Posted on: 4/8/2008 | Category:
C# Interview questions | Views: 12277 |
Answer:
It provides a mechanism that synchronizes access to objects.
The Monitor class controls access to objects by granting a lock for an object to a single thread. Object locks provide the ability to restrict access to a block of code, commonly called a critical section. While a thread owns the lock for an object, no other thread can acquire that lock. You can also use Monitor to ensure that no other thread is allowed to access a section of application code being executed by the lock owner, unless the other thread is executing the code using a different locked object.
For more visit http://msdn2.microsoft.com/en-us/library/system.threading.monitor.aspx
Asked In: Microsoft
|
Alert Moderator
Found interesting? Add this to: