use std::thread;
fn main() {
let mut a = vec![1, 2, 3];
let mut x = 0;
scope_lock::lock_scope(|e| {
thread::spawn({
let f = e.fn_(Box::new(|()| {
println!("hello from the first scoped thread");
dbg!(&a);
}));
move || f(())
});
thread::spawn({
let mut f = e.fn_mut(Box::new(|()| {
println!("hello from the second scoped thread");
x += a[0] + a[2];
}));
move || f(())
});
println!("hello from the main thread");
});
a.push(4);
assert_eq!(x, a.len());
}