When is ReaderWriterLockSlim better than a simple lock?

后端 未结 10 1883
孤街浪徒
孤街浪徒 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:51

    Check out this article: http://blogs.msdn.com/b/pedram/archive/2007/10/07/a-performance-comparison-of-readerwriterlockslim-with-readerwriterlock.aspx

    Your sleeps are probably long enough that they make your locking/unlocking statistically insignificant.

提交回复
热议问题