Let‘s say we wanted to run a program that created two threads, each of which was doing
some independently work, in this case printing "A" or "B". The code is shown in Figure 26.2.
The main program creates two threads, each of which will run the function mythread(),
though with different arguments (the string A or B). Once a thread is created, it may start
running right away (depending on the whims of scheduler); alternatively, it may be put in a
"ready" but not "running" state and thus not run yet. After creating the two threads (T1 and
T2), the main thread calls pthread_join(), which waits for a particular thread to complete.
Operating System: Three Easy Pieces ---An Example: Thread Creation (Note)
原文:http://www.cnblogs.com/miaoyong/p/4939229.html