4 ms·
"avoid holding two locks simultaneously" only guarantees no deadlocks if locks are your only form of inter-thread-blocking. If you have synchronization points
by LukeShu 8y ago
"avoid holding two locks simultaneously" only guarantees no deadlocks if locks are your only form of inter-thread-blocking. If you have synchronization points or channels/pipes or anything else, that needs to be expanded to include "avoid using a channel while you hold a lock" and similar for every blocking primitive.
- kazinator 8y agoThat's right; avoid doing anything that could block while holding a lock: acquiring another lock, waiting on a semaphore, and so on. Note how condition variables have an aspect of this built-in: the wait operation gives up the mutex.