Thread safe method without using any type of lock [closed]

It depends on what you need to do inside the method, however usually a technique called CompareAndSwap can be used. The .NET framework uses the CompareExchange function. In any case you have to check if you can express your lock in a way that is suitable for CAS.

Leave a Comment