()
| 1 | use std::sync::{Arc, Mutex}; |
| 2 | |
| 3 | fn main() { |
| 4 | let x = vec![0, 0]; |
| 5 | let data = Arc::new(Mutex::new(x)); |
| 6 | let mut handles = vec![]; |
| 7 | |
| 8 | for _ in 0..10 { |
| 9 | let mydata = data.clone(); |
| 10 | let h = std::thread::spawn(move || { |
| 11 | let mut y = mydata.lock().unwrap(); |
| 12 | for _ in 0..100_000 { |
| 13 | y[0] += 1; |
| 14 | } |
| 15 | }); |
| 16 | handles.push(h); |
| 17 | } |
| 18 | for h in handles { |
| 19 | h.join().unwrap(); |
| 20 | } |
| 21 | println!("{:?}", *data.lock().unwrap()); |
| 22 | } |
nothing calls this directly
no outgoing calls
no test coverage detected