Saturday, July 20, 2013

C# - Thread Safe Increment, Decrement

When incrementing or decrementing values such as ++i, --i in a multi-threaded program, use the methods from Thread class.

System.Threading.Interlocked.Increment(i);
System.Threading.Interlocked.Decrement(i);

No comments:

Post a Comment