What does it mean to make a dynamic array thread-safe and concurrent?
Say, for example, std::vector.
The only concurrent operations on a single object in the standard library that are safe by default are
- Only accessing const-member functions
- All accesses to synchronization primitives (like mutex lock and unlock or atomic operations)
Everything else has to be externally synchronized. In particular, the standard library doesn't have any thread safe containers yet (as of c++14)
So the answer to both of your examples is no, they both require a form of external synchronization.
What you can do of course is modifying the value of two different elements in the container.