When is ReaderWriterLockSlim better than a simple lock?

后端 未结 10 1902
孤街浪徒
孤街浪徒 2020-11-29 16:16

I\'m doing a very silly benchmark on the ReaderWriterLock with this code, where reading happens 4x more often than writting:

class Program
{
    static void          


        
10条回答
  •  误落风尘
    2020-11-29 16:44

    I guess this is because of the sleeps you have in you reader and writer threads.
    Your read thread has a 500tims 50ms sleep which is 25000 Most of the time it is sleeping

提交回复
热议问题