Top "Interlocked" questions

Provides atomic operations for variables that are shared by multiple threads.

Volatile vs. Interlocked vs. lock

Let's say that a class has a public int counter field that is accessed by multiple threads. This int is …

c# multithreading locking volatile interlocked
Reading interlocked variables

Assume: A. C++ under WIN32. B. A properly aligned volatile integer incremented and decremented using InterlockedIncrement() and InterlockedDecrement(). __declspec (align(8)) …

c++ windows multithreading locking interlocked
Reading an int that's updated by Interlocked on other threads

(This is a repeat of: How to correctly read an Interlocked.Increment'ed int field? but, after reading the answers and …

c# .net multithreading interlocked interlocked-increment
InterlockedIncrement usage

While reading about the function InterlockedIncrement I saw the remark that the variable passed must be aligned on a 32-bit …

c++ multithreading winapi multicore interlocked
Performance of Interlocked.Increment

Is Interlocked.Increment(ref x) faster or slower than x++ for ints and longs on various platforms?

.net performance interlocked interlocked-increment
Using Interlocked.CompareExchange with a class

System.Threading.Interlocked.CompareExchange operator provides atomic (thus thread-safe) C# implementation of the Compare-And-Swap operation. For example int i = 5; Interlocked.…

c# .net multithreading interlocked
Lockless using InterlockedCompareExchange

I am trying to make following snip of code lockless using interlocked operations, Any idea how to translate this? if (…

c++ multithreading synchronization interlocked
C# Interlocked Exchange

I have a bit of my game which looks like this: public static float Time; float someValue = 123; Interlocked.Exchange(ref …

c# interlocked
Is a lock (wait) free doubly linked list possible?

Asking this question with C# tag, but if it is possible, it should be possible in any language. Is it …

c# thread-safety locking lock-free interlocked
Interlocked.CompareExchange<Int> using GreaterThan or LessThan instead of equality

The System.Threading.Interlocked object allows for Addition (subtraction) and comparison as an atomic operation. It seems that a CompareExchange …

c# c++ il interlocked interlocked-increment