1
Reply

What is monitor in C#?

Vinay  Arora

Vinay Arora

11y
1.2k
0
Reply

    Monitor is class in C#.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.Monitor has the following features:It is associated with an object on demand. It is unbound, which means it can be called directly from any context. An instance of the Monitor class cannot be created. The following information is maintained for each synchronized object: A reference to the thread that currently holds the lock. A reference to a ready queue, which contains the threads that are ready to obtain the lock. A reference to a waiting queue, which contains the threads that are waiting for notification of a change in the state of the locked object. For similar kind of C# interview question you can refer this link c# interview questions