CompareExchange : Interlocked : Development Class C# Source Code


Custom Search

C# Source Code » Development Class » Interlocked »

 

CompareExchange








    
 
using System;
using System.Threading;

class MainClass
{
    public static void Main()
    {
        int firstInt = 25;
        int secondInt = 80;

        Console.WriteLine("firstInt initial value = {0}", firstInt);
        Console.WriteLine("secondInt initial value = {0}", secondInt);

        Interlocked.CompareExchange(ref firstInt, 50, secondInt);

        Console.WriteLine("firstInt after CompareExchange = {0}", firstInt);
        Console.WriteLine("secondInt after CompareExchange = {0}", secondInt);
    }
}

 
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Development Class
» Interlocked