mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-27 09:14:20 +00:00
24 lines
425 B
Rust
24 lines
425 B
Rust
// run-pass
|
|
// ignore-emscripten no threads support
|
|
|
|
use std::thread;
|
|
|
|
struct Foo;
|
|
|
|
impl Drop for Foo {
|
|
fn drop(&mut self) {
|
|
println!("test2");
|
|
}
|
|
}
|
|
|
|
thread_local!(static FOO: Foo = Foo);
|
|
|
|
fn main() {
|
|
// Off the main thread due to #28129, be sure to initialize FOO first before
|
|
// calling `println!`
|
|
thread::spawn(|| {
|
|
FOO.with(|_| {});
|
|
println!("test1");
|
|
}).join().unwrap();
|
|
}
|