Protect that state: locks, monitors, and atomics
You need to protect a piece of data, like a counter or an output stream, from getting garbled by multiple threads.
Three choices, hot shot:
- Explicit locks (aka mutexes): acquire a lock around the “critical
section”, munge the data, release the lock. You…
shared via WordPress.com