diff --git a/src/test/run-pass/drop-trait-enum.rs b/src/test/run-pass/drop-trait-enum.rs index f1cc4fb172409..6addfc59a3dac 100644 --- a/src/test/run-pass/drop-trait-enum.rs +++ b/src/test/run-pass/drop-trait-enum.rs @@ -66,7 +66,7 @@ pub fn main() { assert_eq!(receiver.recv().ok(), None); let (sender, receiver) = channel(); - let _t = Thread::spawn(move|| { + let _t = Thread::scoped(move|| { let v = Foo::FailingVariant { on_drop: SendOnDrop { sender: sender } }; }); assert_eq!(receiver.recv().unwrap(), Message::Dropped); @@ -74,7 +74,7 @@ pub fn main() { let (sender, receiver) = channel(); let _t = { - Thread::spawn(move|| { + Thread::scoped(move|| { let mut v = Foo::NestedVariant(box 42u, SendOnDrop { sender: sender.clone() }, sender.clone()); diff --git a/src/test/run-pass/extern-stress.rs b/src/test/run-pass/extern-stress.rs index bb9e94073828a..c3e04177cce7d 100644 --- a/src/test/run-pass/extern-stress.rs +++ b/src/test/run-pass/extern-stress.rs @@ -42,7 +42,7 @@ fn count(n: libc::uintptr_t) -> libc::uintptr_t { pub fn main() { range(0u, 100).map(|_| { - Thread::spawn(move|| { + Thread::scoped(move|| { assert_eq!(count(5), 16); }) }).collect::>(); diff --git a/src/test/run-pass/extern-yield.rs b/src/test/run-pass/extern-yield.rs index 46829e9ba6ef8..f5e91b9de67a9 100644 --- a/src/test/run-pass/extern-yield.rs +++ b/src/test/run-pass/extern-yield.rs @@ -39,7 +39,7 @@ fn count(n: libc::uintptr_t) -> libc::uintptr_t { pub fn main() { range(0, 10u).map(|i| { - Thread::spawn(move|| { + Thread::scoped(move|| { let result = count(5); println!("result = {}", result); assert_eq!(result, 16); diff --git a/src/test/run-pass/issue-9396.rs b/src/test/run-pass/issue-9396.rs index 34bb50c5cf669..73355d15a2759 100644 --- a/src/test/run-pass/issue-9396.rs +++ b/src/test/run-pass/issue-9396.rs @@ -15,7 +15,7 @@ use std::time::Duration; pub fn main() { let (tx, rx) = channel(); - let _t = Thread::spawn(move||{ + let _t = Thread::scoped(move||{ let mut timer = Timer::new().unwrap(); timer.sleep(Duration::milliseconds(10)); tx.send(()).unwrap(); diff --git a/src/test/run-pass/tcp-accept-stress.rs b/src/test/run-pass/tcp-accept-stress.rs index cd3cb872fd3bc..cad7173203483 100644 --- a/src/test/run-pass/tcp-accept-stress.rs +++ b/src/test/run-pass/tcp-accept-stress.rs @@ -34,11 +34,11 @@ fn test() { let (srv_tx, srv_rx) = channel(); let (cli_tx, cli_rx) = channel(); - for _ in range(0, N) { + let _t = range(0, N).map(|_| { let a = a.clone(); let cnt = cnt.clone(); let srv_tx = srv_tx.clone(); - Thread::spawn(move|| { + Thread::scoped(move|| { let mut a = a; loop { match a.accept() { @@ -52,18 +52,18 @@ fn test() { } } srv_tx.send(()); - }); - } + }) + }).collect::>(); - for _ in range(0, N) { + let _t = range(0, N).map(|_| { let cli_tx = cli_tx.clone(); - Thread::spawn(move|| { + Thread::scoped(move|| { for _ in range(0, M) { let _s = TcpStream::connect(addr).unwrap(); } cli_tx.send(()); - }); - } + }) + }).collect::>(); drop((cli_tx, srv_tx)); // wait for senders diff --git a/src/test/run-pass/threads.rs b/src/test/run-pass/threads.rs index c47ca0db2a156..abc2938df00bb 100644 --- a/src/test/run-pass/threads.rs +++ b/src/test/run-pass/threads.rs @@ -13,7 +13,7 @@ use std::thread::Thread; pub fn main() { let mut i = 10; while i > 0 { - Thread::spawn({let i = i; move|| child(i)}); + Thread::scoped({let i = i; move|| child(i)}); i = i - 1; } println!("main thread exiting"); diff --git a/src/test/run-pass/unique-send-2.rs b/src/test/run-pass/unique-send-2.rs index bb3019ede4b57..ba75c7629b514 100644 --- a/src/test/run-pass/unique-send-2.rs +++ b/src/test/run-pass/unique-send-2.rs @@ -19,13 +19,13 @@ pub fn main() { let (tx, rx) = channel(); let n = 100u; let mut expected = 0u; - for i in range(0u, n) { + let _t = range(0u, n).map(|i| { + expected += i; let tx = tx.clone(); - Thread::spawn(move|| { + Thread::scoped(move|| { child(&tx, i) - }); - expected += i; - } + }) + }).collect::>(); let mut actual = 0u; for _ in range(0u, n) { diff --git a/src/test/run-pass/unwind-resource.rs b/src/test/run-pass/unwind-resource.rs index 3f59b2c6c7641..159bac101830a 100644 --- a/src/test/run-pass/unwind-resource.rs +++ b/src/test/run-pass/unwind-resource.rs @@ -37,7 +37,7 @@ fn f(tx: Sender) { pub fn main() { let (tx, rx) = channel(); - let _t = Thread::spawn(move|| f(tx.clone())); + let _t = Thread::scoped(move|| f(tx.clone())); println!("hiiiiiiiii"); assert!(rx.recv().unwrap()); }