1 #include <proto/thread.h>
5 void *thread_sub(void *data
) {
6 uint32_t id
= CurrentThread();
8 printf("[%d] starting sub\n", id
);
12 printf("[%d] exiting sub\n", id
);
14 ExitThread((void*) id
);
19 void *thread_main(void *data
) {
21 uint32_t id_sub
[10], ret
;
22 uint32_t id
= CurrentThread();
24 printf("[%d] starting\n", id
);
28 for (i
= 0; i
< 10; i
++) {
29 id_sub
[i
] = CreateThread(thread_sub
, NULL
);
30 printf("created sub thread %d\n", id_sub
[i
]);
33 printf("[%d] exiting\n", id
);
35 for (i
= 0; i
< 10; i
++) {
36 printf("waiting for sub thread %d\n", id_sub
[i
]);
37 WaitThread(id_sub
[i
], (void **) &ret
);
38 printf("sub thread %d return %d\n", id_sub
[i
], ret
);
41 ExitThread((void*) id
);
46 int main (int argc
, char **argv
) {
50 for (i
= 0; i
< 10; i
++) {
51 id
[i
] = CreateThread(thread_main
, NULL
);
52 printf("created thread %d\n", id
[i
]);
55 for (i
= 0; i
< 10; i
++) {
56 printf("waiting for thread %d\n", id
[i
]);
57 WaitThread(id
[i
], (void **) &ret
);
58 printf("thread %d return %d\n", id
[i
], ret
);