Create threads with a argument. See bin/threads_arg.rs

This commit is contained in:
Yifan Wu 2021-10-08 13:50:36 -07:00
parent c951c1781e
commit 5b56961b8c
11 changed files with 59 additions and 19 deletions

View file

@ -26,9 +26,9 @@ pub fn thread_c() -> ! {
#[no_mangle]
pub fn main() -> i32 {
let mut v = Vec::new();
v.push(thread_create(thread_a as usize));
v.push(thread_create(thread_b as usize));
v.push(thread_create(thread_c as usize));
v.push(thread_create(thread_a as usize, 0));
v.push(thread_create(thread_b as usize, 0));
v.push(thread_create(thread_c as usize, 0));
for tid in v.iter() {
let exit_code = waittid(*tid as usize);
println!("thread#{} exited with code {}", tid, exit_code);