blob: 9d7c2cc5d28ab55d708f0e1ab4ab5f9ed0d3adaa (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
// xfail-boot
// xfail-stage0
// xfail-stage1
// xfail-stage2
fn main() -> () {
log "===== SPAWNING and JOINING TASKS =====";
test00(false);
log "===== SPAWNING and JOINING THREAD TASKS =====";
test00(true);
}
fn start(int task_number) {
log "Started task.";
let int i = 0;
while (i < 10000) {
i = i + 1;
}
log "Finished task.";
}
fn test00(bool create_threads) {
let int number_of_tasks = 8;
let int i = 0;
let vec[task] tasks = vec();
while (i < number_of_tasks) {
i = i + 1;
if (create_threads) {
tasks += vec(spawn thread start(i));
} else {
tasks += vec(spawn start(i));
}
}
for (task t in tasks) {
join t;
}
log "Joined all task.";
}
|