锁定自由构建在.NET中 [英] Lock free constructs in .net

查看:123
本文介绍了锁定自由构建在.NET中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来的.net和想知道.NET是否有相当于Java的AtomicInteger,的ConcurrentLinkedQueue等?

I am new to .net and would like to know whether .net has the java equivalent of AtomicInteger, ConcurrentLinkedQueue, etc?

我做了一些搜索并且不可能拿出任何东西。

I did a bit of search and couldnt come up with anything.

锁定自由算法需要某种形式的一个CAS指令,这是通过无证不安全类的Java提供的,没有.NET有什么相同呢?

The lock free algorithms need some sort of a CAS instruction, which is provided through the undocumented Unsafe class in Java, does .net have anything equivalent?

推荐答案

在.NET中有Interlocked类,静态方法Interlocked.Increment()和Interlocked.Decrement()。

In .NET there is the Interlocked class, with static methods Interlocked.Increment() and Interlocked.Decrement().

请参阅<一href="http://msdn.microsoft.com/en-us/library/system.threading.interlocked.aspx">http://msdn.microsoft.com/en-us/library/system.threading.interlocked.aspx.

您还可以找到在System.Threading命名空间其他原子OCH同步构建。

You will also find other atomic och synchronization constructs in the System.Threading namespace.

这篇关于锁定自由构建在.NET中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆