1use std::thread;
2
3fn main() {
4 let mut a = vec![1, 2, 3];
5 let mut x = 0;
6
7 scope_lock::lock_scope(|e| {
8 thread::spawn({
9 let f = e.fn_(Box::new(|()| {
10 println!("hello from the first scoped thread");
11 dbg!(&a);
13 }));
14 move || f(())
15 });
16 thread::spawn({
17 let mut f = e.fn_mut(Box::new(|()| {
18 println!("hello from the second scoped thread");
19 x += a[0] + a[2];
22 }));
23 move || f(())
24 });
25 println!("hello from the main thread");
26 });
27
28 a.push(4);
30 assert_eq!(x, a.len());
31}