2011-03-25 14:19:20 -05:00
|
|
|
// xfail-stage0
|
2011-07-12 17:27:17 -05:00
|
|
|
|
|
|
|
use std;
|
|
|
|
|
|
|
|
import std::task;
|
|
|
|
|
2011-07-27 07:19:39 -05:00
|
|
|
fn main() { log "===== SPAWNING and JOINING THREAD TASKS ====="; test00(); }
|
2010-07-19 16:05:18 -05:00
|
|
|
|
2011-07-27 07:19:39 -05:00
|
|
|
fn start(task_number: int) {
|
2010-07-19 16:05:18 -05:00
|
|
|
log "Started task.";
|
2011-07-27 07:19:39 -05:00
|
|
|
let i: int = 0;
|
|
|
|
while i < 10000 { i = i + 1; }
|
2010-07-19 16:05:18 -05:00
|
|
|
log "Finished task.";
|
|
|
|
}
|
2011-07-13 17:44:09 -05:00
|
|
|
|
2011-07-12 17:27:17 -05:00
|
|
|
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); }
|
2011-07-13 17:44:09 -05:00
|
|
|
|
2010-07-28 18:58:17 -05:00
|
|
|
log "Joined all task.";
|
2010-07-19 16:05:18 -05:00
|
|
|
}
|