1. use std::sync::{Arc, Mutex};
    2. use std::thread;
    3. fn main() {
    4. let mtx = Arc::new(Mutex::new(""));
    5. let mtx1 = mtx.clone();
    6. let mtx2 = mtx.clone();
    7. let n = 50;
    8. let th1 = thread::spawn(move || {
    9. mtx1.lock().unwrap();
    10. printData(n, "*".to_string());
    11. });
    12. let th2 = thread::spawn(move || {
    13. mtx2.lock().unwrap();
    14. printData(n, "$".to_string());
    15. });
    16. th1.join();
    17. th2.join();
    18. }