When I run the following code, I get some output:
use std::thread::Thread;
static DELAY: i64 = 1000;
fn main() {
Thread::spawn(move || {
println!("some output");
});
std::io::timer::sleep(std::time::duration::Duration::microseconds(DELAY));
}
But if I set DELAY to 999, I get nothing. I think that 999 and 1000 are close enough not to cause such a difference, meaning there must be something else going on here. I've tried also with Duration::nanoseconds (999_999 and 1_000_000), and I see the same behavior.
My platform is Linux and I can reproduce this behavior nearly all the time: using 999 results in some output in way less than 1% of runs.
As a sidenote, I am aware that this approach is wrong.
+ 1to+ 0). – Dogbert Jan 6 '15 at 17:14