Are threads waiting on a lock FIFO?

后端 未结 5 1894
被撕碎了的回忆
被撕碎了的回忆 2021-01-05 03:13

Let\'s say I have the following code

static class ...
{
    static object myobj = new object();

    static void mymethod()
    {
        lock(myobj)
                


        
5条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-05 04:00

    It will wait, and they will NOT be in the same order.

    Depending on your needs, you might have more performance if you look at something like a ReaderWriterLock or something other than just lock

提交回复
热议问题