Running method while destroying the object

前端 未结 8 1584
抹茶落季
抹茶落季 2021-01-12 22:49

A few days ago my friend told me about the situation, they had in their project. Someone decided, that it would be good to destroy the object of NotVerySafeClass

8条回答
  •  无人共我
    2021-01-12 23:31

    Why not make use of a mutex / semaphore ? At the beginning of any method the mutex is locked, and the destructor wait until the mutex is unlocked. It's a fix, not a solution. Maybe you should change the design of a part of your application.

提交回复
热议问题