https://issues.dlang.org/show_bug.cgi?id=6380

Marco Leise <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |[email protected]

--- Comment #1 from Marco Leise <[email protected]> ---
That only works well when you don't use your own synchronization. Otherwise you
may protect stuff in one shared method with your own mutex, and one some other
method you forgot to mark shared, the object's hidden monitor mutex is used,
allowing for two threads to modify the data in parallel.

Just imagine what would happen in this code:

auto cond = cast(shared) new Condition(new Mutex);
synchronized (cond.mutex)
{
   ...
}

... And you just created a new Mutex to protect the Mutex that protects your
critical section.

--

Reply via email to