C # primitive arrays are volatile?

I declare an array like private double[] array = new double[length]. Is it safe to update these array elements in one thread and read in another thread? Will I have an actual cost?

Note. I do not list the array. I access my elements by index.

+4
source share
3 answers

Volatile does not guarantee the freshness of value. It prevents some optimizations, but does not guarantee thread synchronization.

A double does not guarantee that it is updated atomically . Thus, updating / reading double arrays without synchronization will not be thread safe in all senses or without variability, since you can read partially written values.

+2
source

, MSDN:

. , - , . , , , , .

, , , , , .

+4

, . . /.

0
source

All Articles