# How to deadlock Tokio application in Rust with just a single mutex

DevFeed: [How to deadlock Tokio application in Rust with just a single mutex](<https://devfeed.tech/articles/how-to-deadlock-tokio-application-in-rust-with-just-a-single-mutex-5965.md>)

Original publisher: [Read original article](<https://turso.tech/blog/how-to-deadlock-tokio-application-in-rust-with-just-a-single-mutex>)

Author: Piotr Jastrzebski

Published: 2024-09-02T00:00:00Z

Content type: tutorial

Language: en

Sources: [Turso Blog](<https://devfeed.tech/sources/turso-blog.md>)

Topics: [Tokio](<https://devfeed.tech/topics/tokio.md>), [Deadlock](<https://devfeed.tech/topics/deadlock.md>)

Tags: [concurrent-programming](<https://devfeed.tech/tags/concurrent-programming.md>), [deadlock](<https://devfeed.tech/tags/deadlock.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [rust](<https://devfeed.tech/tags/rust.md>), [tokio](<https://devfeed.tech/tags/tokio.md>), [turso](<https://devfeed.tech/tags/turso.md>)

## AI overview

A Tokio-based Rust program deadlocks when a synchronous task holds a std::sync::Mutex while blocking on a future. The article recommends tokio::sync::Mutex for this asynchronous scenario and cautions against premature optimization.

## Source excerpt

Battlefield story of how we managed to deadlock Tokio program with just a single mutex