0

Assume that I have following function:

public void AddItems(List<Item> items)
{
    lock (_locker)
    {
        foreach (var item in items)
        {                   
            Buffer.Enqueue(item);                    
        }
    }
}

This function can be invoked from many different threads.

The lock keyword ensures that one thread does not enter a critical section of code while another thread is in the critical section. If another thread tries to enter a locked code, it will wait, block, until the object is released. MSDN

Although locks ensures that received items do no mix with each other I would like to know what is the invocation sequence of awaiting threads after lock released.

komizo
  • 1,052
  • 14
  • 21

0 Answers0