Faken
Faken

Reputation: 11822

Are new threads created by a function tied to that function or are they independent?

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

Upvotes: 0

Views: 46

Answers (2)

anon
anon

Reputation:

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.

Upvotes: 1

Dewfy
Dewfy

Reputation: 23624

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.

Upvotes: 1

Related Questions