How to

adds two integers as an atomic operation

Published: 24. October 2011 | Updated: 26. October 2011
License: Microsoft Public License (MS-PL)
Categories: Framework » Threading
Tags: C# Threading
Was this snippet helpful for you? YESYES / NONO

Import namespace

using System.Threading;

Code

int i = 100;

Interlocked.Add(ref i, 50);

Console.WriteLine(i);
Console Output:
150
Send us feedback about this snippet »



Related Snippets: