Is it possible to get a thread object for the main thread, and `join()` with it? Is it possible to get a thread object for the main thread, and `join()` with it? multithreading multithreading

Is it possible to get a thread object for the main thread, and `join()` with it?


As pointed out in the comments by @molbdnilo and @yohjb (see also What happens to a detached thread when main() exits?), C++11 semantics say that all threads are ended when the main() function terminates.Since C++11 does not have a pthread_exit() equivalent, the main thread cannot be joined, because the program would end anyway.

So, to answer my question, it does not seem to be possible, and with the terminating semantics of main(), it would not be very useful.