Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using _endthread();

Today I started working on a project where I need use thread's, I'm using functions from process.h: _beginthread and _endthread.

My question is, I really need use _endthread(); at the end of function?

void LGThread(void *null_ptr) {
 /* ... code ...*/
 _endthread();
}
void main() {
 _beginthread(LGThread, NULL, NULL);
}

Or even with:

void LGThread(void *null_ptr) {
 /* ... code ...*/
}
void main() {
 _beginthread(LGThread, NULL, NULL);
}

I'm fine? What it does specially?

like image 873
ernilos Avatar asked May 18 '26 04:05

ernilos


1 Answers

You don't need it. And in a C++ program it can be harmfull: It does not return, so destructors will not be called for objects allocated on the stack in the thread function.

like image 114
ScottMcP-MVP Avatar answered May 20 '26 17:05

ScottMcP-MVP