Quantcast
Channel: .NET Framework Class Libraries forum
Viewing all articles
Browse latest Browse all 8156

Address array element and thread-safe

$
0
0

Hello!

I have red that access to different element of array is thread-safe, but to same is not.

But why this code work without any trouble?

            var array = new int[1];
            Parallel.For(0, 10000000, i => array[0] = i);


Viewing all articles
Browse latest Browse all 8156

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>