27 for (i
= 0; i
< NITER
; i
++) {
31 if (pthread_create(&t
, NULL
, func
, NULL
)) {
33 * sleep and retry once for the case that
34 * the child threads are not finished yet.
36 printf("%d sleeping...\n", i
);
38 if (pthread_create(&t
, NULL
, func
, NULL
))
43 sched_yield(); /* give a chance thread to finish */
44 if (pthread_detach(t
))
47 error
= pthread_join(t
, NULL
);
48 if (error
!= ESRCH
&& error
!= EINVAL
) {
49 printf("unexpected error %d\n", error
);