# If a thread containing main terminates, can another thread do anything?

I'm studying threads in C and I have this theoretical question in mind that is driving me crazy. Assume the following code:

1) void main() {
3) }


After line 2 is executed, two paths of execution are created. However I believe that immediately after line 2 is executed then it doesn't even matter what the new thread does, which was created at line 2, because the original thread that executed line 2 will end the entire program at its next instruction. Am I wrong? is there any chance the original thread gets suspended somehow and the new thread get its chance to do something (assume the code as is, no sync between threads or join operations are performed)

• That would depend on what the termination conditions of the program are. Does it terminate when the thread containing main terminates? Or when the last spawned subthread terminates? If your question is specific to C, you should ask on Stack Overflow. – David Richerby Mar 27 '14 at 15:33