What is the difference between std sync and tokio sync

std::sync blocks threads for concurrency, while tokio::sync yields control to async runtimes for non-blocking operations.

std::sync provides blocking primitives for multi-threaded programs, while tokio::sync provides non-blocking primitives for async runtimes. Use std::sync when you need to block a thread until a resource is available, and tokio::sync when you need to yield control to an async runtime without blocking.

use std::sync::Mutex; // Blocks the thread
use tokio::sync::Mutex; // Yields to the runtime