GDB - threads

The debuggers can swim in multithreaded programs quite as well as single-threaded ones. Here's the previous program, now doing its calculations in threads:

// broken-program-2/src/ extern crate num; use num::Num; use std::thread; use std::sync::{Arc, Mutex}; fn multiply_and_store<N: Num + Copy + Send>(nums: Arc<Mutex<Vec<N>>>, num: N, multiplier: N) {     let mut data = nums.lock().unwrap();     data.push(num * multiplier); } fn multiply_numbers_by<N: 'static + Num + Copy + Send>(nums: Vec<N>, multiplier: N, ret: Arc<Mutex<Vec<N>>>) {     let mut threads = vec!();     for num in nums {         let ret = ret.clone();         threads.push(thread::spawn(move || {             multiply_and_store(ret, num, multiplier);         }));     }     for thread in threads {  let _ ...

Get Mastering Rust now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.