]>
Commit | Line | Data |
---|---|---|
c1a9b12d SL |
1 | // Copyright 2015 The Rust Project Developers. See the COPYRIGHT |
2 | // file at the top-level directory of this distribution and at | |
3 | // http://rust-lang.org/COPYRIGHT. | |
4 | // | |
5 | // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | |
6 | // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | |
7 | // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | |
8 | // option. This file may not be copied, modified, or distributed | |
9 | // except according to those terms. | |
10 | ||
7453a54e SL |
11 | // ignore-emscripten no threads support |
12 | ||
92a42be0 | 13 | use std::thread; |
e9174d1e | 14 | |
c1a9b12d | 15 | struct Foo; |
c1a9b12d SL |
16 | |
17 | impl Drop for Foo { | |
18 | fn drop(&mut self) { | |
92a42be0 | 19 | println!("test2"); |
c1a9b12d SL |
20 | } |
21 | } | |
22 | ||
92a42be0 | 23 | thread_local!(static FOO: Foo = Foo); |
e9174d1e | 24 | |
c1a9b12d | 25 | fn main() { |
92a42be0 SL |
26 | // Off the main thread due to #28129, be sure to initialize FOO first before |
27 | // calling `println!` | |
28 | thread::spawn(|| { | |
c1a9b12d | 29 | FOO.with(|_| {}); |
92a42be0 | 30 | println!("test1"); |
c1a9b12d SL |
31 | }).join().unwrap(); |
32 | } |