5 thread_function (void *arg)
9 printf ("Thread <%d> executing\n", x);
15 main (int argc, char **argv)
18 pthread_t threads[256];
21 pthread_attr_init (&attr);
23 /* Create a ton of quick-executing threads, then wait for them to
25 for (i = 0; i < 1000; ++i)
27 for (j = 0; j < 256; ++j)
29 pthread_create (&threads[j], &attr, thread_function,
30 (void *)(i * 1000 + j));
33 for (j = 0; j < 256; ++j)
35 pthread_join (threads[j], NULL);
39 pthread_attr_destroy (&attr);