The only ordering guarantees here are that pthread_join(th1, NULL);
will not return until thread 1 has exited and pthread_join(th2, NULL);
will not return until thread 2 has exited. Consequently, the main()
function will not return (and the process will not exit) until both thread 1 and thread 2 have exited.
There is no ordering imposed between thread 1 and thread 2 - their execution can be arbitrarily interleaved.