Is it right that the new one is on the stack and you donโt need your own mutex?
The new[]() operator works the same as new() , but instead of selecting one object, it allocates an array of objects. I donโt know what this is about the stack, selected objects are allocated on the heap, and a pointer to this memory is returned to you.
The only thing on the stack is the pointer itself, but this happens in both versions of new .
Having seen that new[]() calls new() , and then , I see no reason why you need a mutex in new[]() , because new() already protected by the mutex. Any thread that calls new[]() will have to wait if the other is already inside new() .
source share