Let's summarize the takeaway points:
- We should design lock-free threads when possible
- Lock-free threads tend to perform better compared to heavily synchronized/sequential threads
- Mutex is a mutually exclusive synchronization primitive
- Mutex helps synchronize the access of shared resources, one thread at a time
- Deadlocks occur due to bad use of mutex, or in general, due to bad use of any synchronization primitives
- Deadlocks are the outcome of logical or design issues
- Deadlocks can be detected with the Helgrind/Valgrind open source tools in Unix and Linux OS