I have an application that has an array of pointers to MyObject objects:
MyObject **arr;
arr= new MyObject*[10];
The application has two threads, these threads will create and delete new MyObject() to array arr. Therefore arr[n] will be changed all the time, however the MyObject‘s themselves do not change.
Should I just declare:
volatile MyObject **arr;
Or should I go with:
MyObject ** volatile arr;
Thanks in advance
I think you need
MyObject * volatile * arr;.Please note though that volatile is not an atomic variable or a valid method of synchronization.
Edit: Here it is: http://drdobbs.com/high-performance-computing/212701484