System.Threading.Monitor.Pulse RRS feed

  • Question

  • Hello,

    I am trying to write a thread-safe AVL Tree data structure (not to be confused with a threaded AVL Tree). I mean multi-threading.

    I was wondering if the "Monitor.Pulse(myLock)" method notifies the oldest waiting thread. In short, does the pulse method preserve the First-In-First-Out algorithm?

    This is very important, because I have two types of locks (one for readers and one for writers). I want to optimize this by allowing all chronologically adjacent reader threads to be processed simultaneously, but queued readers must wait for processing writers and vise-versa.

    If the pulse method does not preserve the "FIFO" algorithm, I have to track that manually.


    Thursday, November 21, 2013 3:02 AM


  • Yes. It follows FIFO logic. MSDN too Says that.

    "When the thread that invoked Pulse releases the lock, the next thread in the ready queue acquires the lock."

    Please mark this post as answer if it solved your problem. Happy Programming!

    • Marked as answer by Zachary Patten Thursday, November 21, 2013 6:11 AM
    Thursday, November 21, 2013 5:22 AM