diff options
Diffstat (limited to 'tests/join1.c')
-rw-r--r-- | tests/join1.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/tests/join1.c b/tests/join1.c index f206c0b..c29e5e6 100644 --- a/tests/join1.c +++ b/tests/join1.c @@ -9,12 +9,14 @@ void * func(void * arg) { - Sleep(1000); + int i = (int) arg; + + Sleep(i * 500); - pthread_exit(arg); + pthread_exit(arg); - /* Never reached. */ - exit(1); + /* Never reached. */ + exit(1); } int @@ -30,6 +32,9 @@ main(int argc, char * argv[]) assert(pthread_create(&id[i], NULL, func, (void *) i) == 0); } + /* Some threads will finish before they are joined, some after. */ + Sleep(1000); + for (i = 0; i < 4; i++) { assert(pthread_join(id[i], (void *) &result) == 0); |