3 #cc: additional_flags=-pthread
4 #output: Starting process a\naaaaaaaaStarting process b\nababbbbbbbbb
6 The output will change depending on the exact syscall sequence per
7 thread, so will change with glibc versions. Prepare to modify; use
10 This file is from glibc/linuxthreads, with the difference that the
11 number is 10, not 10000. */
13 /* Creates two threads, one printing 10000 "a"s, the other printing
15 Illustrates: thread creation, thread joining. */
26 fprintf (stderr, "Starting process %s\n", (char *) arg);
27 for (i = 0; i < 10; i++)
29 write (1, (char *) arg, 1);
41 retcode = pthread_create (&th_a, NULL, process, (void *) "a");
43 fprintf (stderr, "create a failed %d\n", retcode);
44 retcode = pthread_create (&th_b, NULL, process, (void *) "b");
46 fprintf (stderr, "create b failed %d\n", retcode);
47 retcode = pthread_join (th_a, &retval);
49 fprintf (stderr, "join a failed %d\n", retcode);
50 retcode = pthread_join (th_b, &retval);
52 fprintf (stderr, "join b failed %d\n", retcode);