tags:

views:

17

answers:

2

Hello everyone,

Quick question: Are new threads created by a function tied to that function or are they independent as in the function that called them can end before the threads are finished?

Thanks

+1  A: 

Threads are independent OS-level objects, in terms of your question they are tied to process. So function can start one and don't wait until thread done.

Dewfy
Thank you. That answers my question.
Faken
+1  A: 

There is no relationship between a function that starts a thread and the thread. However, if a function creates an object of some thread wrapper class type, it should either wait for the wrapped thread to end, or pass the object on somehow on function exit.

anon
Not a helpful comment, and one that may confuse beginners in thread programming.
anon