我有以下程序:
public class Program
{
struct Foo
{
public int Bar;
public int Zoo;
}
public static void Main()
{
Foo a;
Foo b;
a.Bar = 5;
a.Zoo = 2;
b.Bar = 5;
a.Zoo = 2;
Foo c;
c.Bar = 3;
c.Zoo = 5;
var result = Interlocked.CompareExchange(ref a, b, c);
}
}
我该如何进行编译?
基本上不能。该框架没有提供对任意结构执行原子无锁操作的方法。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句