How to lock a variable used in multiple threads

前端 未结 6 2267
花落未央
花落未央 2021-02-13 02:47

I have asked a question badly over here Lock on a variable in multiple threads so for clarity I am going to ask it here and hope I can ask it correctly.

classA
          


        
6条回答
  •  [愿得一人]
    2021-02-13 03:04

    ClassB shouldn't be exposing a variable (by which you probably mean data member). Expose a property or set of methods instead, and use ReaderWriterLockSlim to handle multiple threads.

提交回复
热议问题