hello All,
I am trying to write a multi threaded program in C++ , but it suddenly exits and i can not understand what happens , it actually do not get any error message or exceptions error , just get out of the program. need your help, thanks .
#include<windows.h>
void Create(DWORD);
static DWORD WINAPI ThreadFunc(LPVOID);
int main(){
............
}
void Create(DWORD ID){
HANDLE hThread;
hThread=creatThread( Null, 0, ThreadFunc, Null, 0, &ID);
}
DWORD WINAPI ThreadFunc(LPVOID param){
TBS *ptbs = new TBS();
ptbs->TbsStart();
delete ptbs;
return 0;
}
in "ThreadFunc" i make an object of TBS class , when the program reaches to this line exits , and sometimes in "ptbs->TbsStart()" exits , it seems it can not allocate memory to "TBS" but I'm not sure because i get no error message!
I'm really confused , please help me.