On 5/19/2013 4:06 PM, deadalnix wrote:
On Sunday, 19 May 2013 at 22:32:58 UTC, Andrei Alexandrescu wrote:
How was there a bug if everything was properly synchronized? You either
describe the matter with sufficient detail, or acknowledge the destruction of
your anecdote. This is going nowhere.


I explained over and over. A field is initialized to null, while the object lock
is owned, and later to its value, while it is locked. In the meantime, another
thread access the object, owning the lock, assuming the field is always
initialized.

so, you have:
==========================
Thread A     Thread B

lock
   p = null
unlock
             lock
                *p = ...
             unlock
lock
   p = new ...
unlock
==========================
Although you are using locks, it still isn't properly synchronized. Changing the p=null to p=someothernonnullvalue will not fix it.

Reply via email to