3 ms·
The thread lifetime is also scope-bound, to ensure the thread dies before any object it might be referring to does.
by mgaunard 4y ago
The thread lifetime is also scope-bound, to ensure the thread dies before any object it might be referring to does.
- mihaigalos 4y agoSorry, I meant how to guard against race conditions where multiple threads try to write to the same shared memory? This is clasically done via memory synchronization mechanisms/atomics.
- mgaunard 4y agoI don't understand how this has anything to do with lifetime management, which is what GC/RC/ARC are for. You do need to synchronize concurrent access to the same object, and it's not just concurrent writes, it's concurrent accesses if at least one of them is a write.