How to lock a variable used in multiple threads

前端 未结 6 2266
花落未央
花落未央 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

    The easiest solution: Don't share the instance of ClassB among your threads.

    In other words, instantiate a new ClassB with your thread declaration and send it as a parameter.

提交回复
热议问题