2011-07-29 22:09:25 -07:00
|
|
|
use std;
|
2011-08-15 16:38:23 -07:00
|
|
|
import std::vec;
|
2011-07-29 22:09:25 -07:00
|
|
|
import std::task;
|
|
|
|
import std::uint;
|
|
|
|
import std::str;
|
|
|
|
|
|
|
|
fn f(n: uint) {
|
|
|
|
let i = 0u;
|
|
|
|
while i < n {
|
2011-08-17 11:44:35 -07:00
|
|
|
let thunk = g;
|
|
|
|
task::join_id(task::spawn(thunk));
|
2011-07-29 22:09:25 -07:00
|
|
|
i += 1u;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn g() {}
|
|
|
|
|
2011-08-13 22:34:16 -07:00
|
|
|
fn main(args: [str]) {
|
2011-07-29 22:09:25 -07:00
|
|
|
|
2011-08-15 16:38:23 -07:00
|
|
|
let n = if vec::len(args) < 2u {
|
2011-07-29 22:09:25 -07:00
|
|
|
10u
|
|
|
|
} else {
|
2011-08-13 22:34:16 -07:00
|
|
|
uint::parse_buf(str::bytes(args.(1)), 10u)
|
2011-07-29 22:09:25 -07:00
|
|
|
};
|
|
|
|
let i = 0u;
|
|
|
|
while i < n {
|
2011-08-17 11:44:35 -07:00
|
|
|
task::spawn(bind f(n));
|
2011-07-29 22:09:25 -07:00
|
|
|
i += 1u;
|
|
|
|
}
|
2011-08-15 11:34:12 -07:00
|
|
|
}
|