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

送出 Pulse 的物件。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.

Pulse、和方法Wait必須從已同步處理的程式碼區塊中叫用。 PulseAllThe 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.

適用於

另請參閱