Guest User

Untitled

a guest
Feb 16th, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. use std::thread;
  2. use std::sync::{Arc, Mutex};
  3. use std::collections::HashMap;
  4.  
  5. fn main() {
  6. let resps = Arc::new(Mutex::new(HashMap::new()));
  7. let resps_inner = resps.clone();
  8. let resps_inner2 = resps.clone();
  9. thread::spawn(move || {
  10. let mut resps = resps_inner.lock().unwrap();
  11. resps.insert(1, 2);
  12. });
  13. thread::spawn(move || {
  14. let mut resps = resps_inner2.lock().unwrap();
  15. unimplemented!();
  16. });
  17. }
Add Comment
Please, Sign In to add comment