|
From: Abhijit S. <mu...@gm...> - 2002-06-16 06:55:43
|
> Is there any function call like join() of java, in
> C++.
GetExitCodeThread(HANDLE, LPDWORD exit_code) tells you the exit code of the
thread. exit_code is STILL_ACTIVE if the thread is running, the actual exit
code if it has completed. For example,
#include <iostream.h>
#include <windows.h>
DWORD WINAPI ThreadProc(LPVOID );
int main()
{
for(int i = 0;i<3;i++)
{
DWORD threadId;
DWORD exit_code;
HANDLE hThread;
hThread = CreateThread(NULL,0,ThreadProc,&i,0,&threadId);
if(hThread == NULL)
cout << "\n Thread has not been created";
else
{
//_getch();
cout << "\n Thread has been created successfully.";
do
{
GetExitCodeThread(hThread, &exit_code);
} while(exit_code == STILL_ACTIVE);
cout << "\n Thread " << i+1 << " has completed.\n";
}
}
return 0;
}
DWORD WINAPI ThreadProc( LPVOID lpParam )
{
cout << "\n Entered threadProc...";
MessageBox(NULL,"sample output","",MB_OK);
for(int i = 0;i<10;i++)
{
cout << "\n thread output is:"<<HIWORD(lpParam) << ".."<<i;
}
return 0;
}
--------------------------
http://mudeth.tripod.com
|