rust/src/test/run-pass/task-comm-2.rs

26 lines
510 B
Rust
Raw Normal View History

// xfail-stage0
use std;
import std::task;
2011-07-27 07:19:39 -05:00
fn main() { log "===== SPAWNING and JOINING THREAD TASKS ====="; test00(); }
2011-07-27 07:19:39 -05:00
fn start(task_number: int) {
log "Started task.";
2011-07-27 07:19:39 -05:00
let i: int = 0;
while i < 10000 { i = i + 1; }
log "Finished task.";
}
fn test00() {
2011-07-27 07:19:39 -05:00
let number_of_tasks: int = 8;
let i: int = 0;
let tasks: vec[task] = [];
while i < number_of_tasks { i = i + 1; tasks += [spawn start(i)]; }
for t: task in tasks { task::join(t); }
2010-07-28 18:58:17 -05:00
log "Joined all task.";
}