Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
MSDN Library

Interlocked Functions

Windows Mobile 6.5
A version of this page is also available for

Interlocked functions synchronize access to a variable that is shared by multiple threads.

Their purpose is to prevent a thread from being preempted while it is incrementing or checking a variable.

The threads of different processes can use these functions as long as their variables share memory.

The following table describes the interlocked functions that Windows Mobile supports.

Function Description


Increments a shared variable, and checks the resulting value.


Decrements a shared variable, and checks the resulting value.


Exchanges the values of specified variables.


Exchanges the values of specified variables if one variable is set to a specified value.


Compares the values of specified values and exchange the values based on the outcome.


Performs an atomic addition of an increment value to an addend value.


Performs an atomic comparison of specified values, and exchanges the values, based on the outcome of the comparison.


Atomically exchanges a pair of values.

Community Additions

© 2015 Microsoft