
26.09.2009, 14:56
|
|
Постоянный
Регистрация: 16.08.2006
Сообщений: 640
С нами:
10386906
Репутация:
599
|
|
Код:
#include <iostream>
#include <process.h>
using namespace std;
unsigned __stdcall SecondThreadFunc( void* pArguments )
{
int* param_index = (int*)pArguments;
int local_index = *param_index;
delete param_index;
cout << local_index << '\n';
_endthreadex( 0 );
return 0;
}
void main()
{
unsigned int threadID;
for(int i = 0; i < 5; i++){
_beginthreadex( NULL, 0, &SecondThreadFunc, new int(i), 0, &threadID );
}
system("pause");
}
На выходе имеем:
0
2
4
3
1
Press any key to continue . . .
|
|
|