exchange objects as an atomic operation
Published: 24. October 2011 | Updated: 26. October 2011License: Microsoft Public License (MS-PL)
Categories: Framework » Threading
Tags: C# Threading
Import namespace
using System.Threading;
Code
var i = 100; // can be double, float, int, IntPtr, long and object Interlocked.Exchange(ref i, 30); Console.WriteLine(i);Console Output:
30
| Send us feedback about this snippet » |





