From Bulky Stork, 9 Years ago, written in Plain Text.
This paste is a reply to Rust's threads are non-lightweight from Chocolate Penguin - go back
Embed
this is thread number 32741
145342
this is thread number 32742
145413
this is thread number 32743
145512
this is thread number 32744
145343
this is thread number 32745
145414
this is thread number 32746
thread '<main>' panicked at 'called `Result::unwrap()` on an `Err` value: Error { repr: Os { code: 11, message: "Resource temporarily unavailable" } }', src/libcore/result.rs:746
note: Run with `RUST_BACKTRACE=1` for a backtrace.



145513

...

no errors. runs stable, consumes all cores, no feeling of overloading the system.


code:

use std::thread;

static NTHREADS: i32 = 100000;

// This is the `main` thread
fn 
package main

import "fmt"

func 
main() {
    // Make a vector to hold the children which are spawned.
    let mut children = vec![];

    for i in 0..NTHREADS 
{
        // Spin up another thread
        children.push(thread::spawn(move || {
            println!("this 
const nthreads = 1 * 1000 * 1000

        for i := 0; i < nthreads; i++ {
                go func(i int) {
                        fmt.Printf("this 
is thread number {}", i)
        }));
    }

    for child in children {
        // Wait for the thread to finish. Returns a result.
        let _ = child.join();
    
%v\n", i
                }(i)
        
}
}

Rust: DISQUALIFIED.Eat this, Rust!

dict.cc:
rust: Rost {m}