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

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

问题描述

我是.net的新用户,想知道.net是否具有与AtomicInteger,ConcurrentLinkedQueue等等相同的Java?



我做了一些搜索和



无锁算法需要某种CAS指令,它是通过Java中未公开的Unsafe类提供的,.net有任何等价的?在.NET中有一个Interlocked类,有静态方法Interlocked.Increment()和Interlocked.Decrement()。



查看 http://msdn.microsoft.com/en-us/library/system.threading.interlocked.aspx



您还会发现其他System.Threading命名空间中的原子och同步结构。


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.

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?

解决方案

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

See http://msdn.microsoft.com/en-us/library/system.threading.interlocked.aspx.

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

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

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