Threads, channels, Mutex, Arc, Send and Sync, async and await, futures and tokio basics.
34 cards · basic cards · AI-written, checked twice. Edit anything.
- What does thread::spawn return?
Show answer
JoinHandle<T>
- What does JoinHandle::join() do?
Show answer
Blocks until the thread completes and returns Result<T, E>
- What trait must a closure passed to thread::spawn implement?
Show answer
Send + 'static
- What is Arc?
Show answer
Atomic Reference Counting, a thread-safe shared ownership pointer
- When should you use Arc instead of Rc?
Show answer
When sharing data across multiple threads
- What does Arc::clone() do?
Show answer
Increments the reference count and returns another Arc to the same data
- What is Mutex?
Show answer
A lock ensuring only one thread can access the protected data at a time
- What does Mutex::lock() return?
Show answer
Result<MutexGuard<T>>
- What is MutexGuard?
Show answer
An RAII guard that holds the lock until it is dropped
- What is the Send trait?
Show answer
A marker trait indicating a type is safe to transfer ownership between threads
- What is the Sync trait?
Show answer
A marker trait indicating a type is safe to share &T references between threads
- Are all Send types also Sync?
Show answer
No, Send and Sync are independent traits
- What is RwLock?
Show answer
A lock allowing multiple concurrent readers or one exclusive writer
- When should you prefer RwLock over Mutex?
Show answer
When you have many readers and few writers
- What does mpsc::channel() return?
Show answer
(Sender<T>, Receiver<T>)