parking_lot provides faster, fairer, and more flexible synchronization primitives than std Mutex by using adaptive spinning and avoiding platform-specific deadlocks. It is the preferred choice for high-performance concurrent Rust code.
use parking_lot::Mutex;
let data = Mutex::new(0);
let lock = data.lock();
Unlike std::sync::Mutex, parking_lot::Mutex does not panic on poison; it returns an error type you must handle, allowing you to decide how to recover from a thread panic.