Skip to content

The example in the concurrency guide is incorrect #20844

Closed
@reem

Description

@reem

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions