Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ExitThread versus Allowing Thread Function to Exit Normally - C++

My application has a thread that is created using CreateThread. What is the difference between calling ExitThread from within said thread and allowing the thread to exit normally (i.e. reaching the end of the thread function)? I am using C++ and Visual Studio 2008. Thanks.

like image 518
Jim Fell Avatar asked Nov 19 '10 15:11

Jim Fell


1 Answers

Actually, something very important:

..., in C++ code, the thread is exited before any destructors can be called or any other automatic cleanup can be performed. Therefore, in C++ code, you should return from your thread function

(Edit Source)

like image 190
Moo-Juice Avatar answered Sep 21 '22 04:09

Moo-Juice