concurrencyperformancedeadlock

Arc<Mutex<Vec<T>>> as default shared state

Using a global mutex-guarded vector when message passing would do.

Why this looks tempting

Feels familiar to anyone coming from threaded languages — share memory, lock it.

Why wrong

Every reader and every writer contends on the same lock. Throughput collapses, and holding the guard across an .await deadlocks the runtime.

Fix

Pass ownership through channels — one task owns the data, others send messages. The type system enforces the discipline; no runtime locking is needed.

Canonical alternative

concurrency/channels