0

What happens to thread run under Windows OS, when the timeout occurs using boost::thread::timed_join, and the waiting thread finishes? Does the thread remain or it finishes along with the process?

Igor R.
  • 14,716
  • 2
  • 49
  • 83
Marc Andreson
  • 3,405
  • 5
  • 35
  • 51

1 Answers1

1

It doesn't matter why a thread finishes (exits), what matters is whether this is the main thread or not: if it's the main thread, then the whole process exits, and all its threads get terminated; if it's a non-main thread, its graceful exit doesn't affect any other threads.

The following article explains a process termination in detail.

Igor R.
  • 14,716
  • 2
  • 49
  • 83
  • The main thread waits for other one it started. Are you absolutely sure the thread does not remain in OS and releases its resources? – Marc Andreson Jul 31 '12 at 17:15
  • @MarcAndreson please note that you mix 2 different questions: 1) whether process' threads get closed on process exit; 2) whether all process resources get freed on process exit. Please, see the following link: http://msdn.microsoft.com/en-us/library/windows/desktop/ms686722(v=vs.85).aspx – Igor R. Jul 31 '12 at 17:28