This is effectively a exact copy of the code in the excellent rust book's "Dining Philosophers" example with two changes.
-
std::time::sleep_ms
has been deprecated since the version of the book with this example was released. Instead this usesstd::time::Duration::from_millis
. -
Added an extra sleep between grabbing forks. Without it I couldn't replicate a deadlock.