Your process, and its threads, die when main() returns. Get the thread handle and wait on it before returning from main().

gg