摘要: use std::sync::mpsc; use std::thread; use std::time::Duration; fn main() { let (tx, rx) = mpsc::channel(); thread::spawn(move || { let vals = vec![ St 阅读全文
posted @ 2024-03-12 22:16 Zhentiw 阅读(3) 评论(0) 推荐(0) 编辑
摘要: A channel has two halves: a transmitter and a receiver. The transmitter half is the upstream location where you put rubber ducks into the river, and t 阅读全文
posted @ 2024-03-12 22:12 Zhentiw 阅读(3) 评论(0) 推荐(0) 编辑
摘要: Arc<T> is a type like Rc<T> that is safe to use in concurrent situations. The a stands for atomic, meaning it’s an atomically reference counted type. 阅读全文
posted @ 2024-03-12 16:05 Zhentiw 阅读(7) 评论(0) 推荐(0) 编辑
摘要: We ofter use movewith closures passed to thread::spawnbecase the closure will then take ownership of the values it uses from the environment, thus tra 阅读全文
posted @ 2024-03-12 15:34 Zhentiw 阅读(4) 评论(0) 推荐(0) 编辑