Skip to content
makolyte

makolyte

Solve real coding problems

  • About
  • C#
  • SQL

interlocked-exchange

C# – Thread-safe bool properties using Locks vs Interlocked

01/26/202512/06/2020 by Mak

The following bool property is not thread-safe. Why is this thread un-safe? Let’s say you have two threads running at the same time. One thread is reading the bool property, while the other thread is changing the value from false to true. It’s possible for the reader thread to get the stale value (false instead … Read more

Categories C# Tags interlocked, interlocked-exchange, lock, multithreading
About โ€ข Privacy Policy
© 2025 makolyte