Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The example in the concurrency guide is incorrect #20844

Closed
reem opened this issue Jan 10, 2015 · 1 comment · Fixed by #21020
Closed

The example in the concurrency guide is incorrect #20844

reem opened this issue Jan 10, 2015 · 1 comment · Fixed by #21020

Comments

@reem
Copy link
Contributor

reem commented Jan 10, 2015

The offending example is:

use std::thread::Thread;

fn main() {
    for _ in 0..10 {
        Thread::spawn(|| {
            println!("Hello World!");
        });
    }
}

With the new detaching thread semantics, this is incorrect since main can exit before all the detached threads have printed.

@steveklabnik
Copy link
Member

I think that this was in the intro as well.

steveklabnik added a commit to steveklabnik/rust that referenced this issue Jan 12, 2015
Thank you @bluss for the suggested implementation.

Fixes rust-lang#20844
alexcrichton added a commit to alexcrichton/rust that referenced this issue Jan 15, 2015
Thank you @bluss for the suggested implementation.

Fixes rust-lang#20844
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants