<br /> <br /> bool killthread1 = false,killthread2=false;<br /> void thread1()<br /> {<br /> while(1)<br /> {<br /> if (killthread1)<br /> {<br /> printf("thread1 killed\n");<br /> return;<br /> }<br /> }<br /> }<br /> <br /> void thread2()<br /> {<br /> while(1)<br /> {<br /> if (killthread2)<br /> {<br /> printf("thread2 killed\n");<br /> return;<br /> }<br /> }<br /> }<br /> <br /> int _tmain(int argc, _TCHAR* argv[])<br /> {<br /> HANDLE th1 = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)(thread1),NULL,0,0);<br /> HANDLE th2 = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)(thread2),NULL,0,0);<br /> getch();<br /> killthread1=killthread2=true;<br /> getch();<br /> return 0;<br /> }<br />
CloseHandle
Process Explorer
CloseHandle()
th1
th2
wrote:bool killthread1 = false,killthread2=false;
wrote:but two thread created will not be ended if i view the handles in process explorer
volatile
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)