As only reference types and a few primitives (including float, but not double, I'm not sure the reason why, I'm happy to hear why) can be declared as volatile, if I wrap a double in a class then declare it as volatile (as below), will the double property be 'read write' thread safe as any other volatile, or should I still be looking at locking?
public class MyThreadedClass
{
volatile VolatileDouble voldub;
}
public class VolatileDouble
{
public double Double { get; set; }
}
See Question&Answers more detail:os