Notifies a thread in the waiting queue of a change in the object's state.
[Visual Basic] Public Shared Sub Pulse( _ ByVal obj As Object _ ) [C#] public static void Pulse( object obj ); [C++] public: static void Pulse( Object* obj ); [JScript] public static function Pulse( obj : Object );
Exception Type | Condition |
---|---|
ArgumentNullException | If obj is a null reference (in Visual Basic Nothing). |
SynchronizationLockException | If this method is not called inside a synchronized block of code. |
The thread that currently holds the lock on the object invokes this method in order to Pulse one of the threads in the waiting queue of a change in the object's state. Shortly after the call to Pulse, the next thread in the waiting queue is moved to the ready queue. The thread that invoked Pulse releases the lock, and the next thread (if there is one) in the ready queue is allowed to take control of the lock.
Note that a synchronized object holds several references, including a reference to the thread that currently holds the lock, a reference to the ready queue, which contains the threads that are ready to obtain the lock, and a reference to the waiting queue, which contains the threads that are waiting for notification of a change in the object's state. The Pulse, PulseAll, and Wait methods must be invoked from within a synchronized block of code. The examples in the description for Wait(Object, Int32) resolve an issue that arises when Pulse is invoked before Wait.
Monitor Class | Monitor Members | System.Threading Namespace | Thread