Monitor.PulseAll(Object) Monitor.PulseAll(Object) Monitor.PulseAll(Object) Monitor.PulseAll(Object) Method

定义

通知所有的等待线程对象状态的更改。Notifies all waiting threads of a change in the object's state.

public:
 static void PulseAll(System::Object ^ obj);
public static void PulseAll (object obj);
static member PulseAll : obj -> unit
Public Shared Sub PulseAll (obj As Object)

参数

obj
Object Object Object Object

发送脉冲的对象。The object that sends the pulse.

异常

调用线程不拥有指定对象的锁。The calling thread does not own the lock for the specified object.

注解

当前拥有指定对象上的锁的线程调用此方法以向等待获取锁的对象上的所有线程发出都信号。The thread that currently owns the lock on the specified object invokes this method to signal all threads waiting to acquire the lock on the object. 发送信号后,等待线程会移到准备就绪的队列。After the signal is sent, the waiting threads are moved to the ready queue. 该线程的调用时PulseAll释放锁后,在准备就绪的队列中的下一个线程获取该锁。When the thread that invoked PulseAll releases the lock, the next thread in the ready queue acquires 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.

PulsePulseAll,和Wait方法必须从调用代码的同步块内。The Pulse, PulseAll, and Wait methods must be invoked from within a synchronized block of code.

备注Pulse解释发生的方法如果Pulse没有线程处于等待状态时调用。The remarks for the Pulse method explain what happens if Pulse is called when no threads are waiting.

若要通知一个线程的信息,请使用Pulse方法。To signal a single thread, use the Pulse method.

适用于

另请参阅