As you experiment more with threads, you may see the warning "
A thread exited while %d other threads were still running", that is caused by the main thread finishing before the spawned threads. Also watch out for using "exit" or "die" in thread code blocks, that will exit the entire program.