I am new to .net and would like to know if the .net has the java equivalent of AtomicInteger, ConcurrentLinkedQueue, etc.?
I searched a little and could not think of anything.
Blocking algorithms require some kind of CAS instruction, which is provided through the Unsafe undocumented class in Java, does .NET have anything equivalent?
.NET has an Interlocked class with the static methods Interlocked.Increment () and Interlocked.Decrement ().
See http://msdn.microsoft.com/en-us/library/system.threading.interlocked.aspx .
System.Threading och.
.Net. , , , ..
RantPack
Interlocked , , , , , .. http://msdn.microsoft.com/en-us/library/system.threading.interlocked_members.aspx
"". , , /. http://msdn.microsoft.com/en-us/library/system.collections.queue.synchronized.aspx
, , (), .NET 4.0 CCR/TPL . TPL, , , ( ..).
.., Interlocked ..
Interlocked
, .net Interlocked class.
, . , .
.net, -
int counter; void code(){ myThreadVal = Interlocked.increment(counter); }
, , myThreadVal.
java AtomicInteger , .