DWORD __stdcall MyThread LPVOID lpThreadParameter char new char 100 Sl

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
DWORD __stdcall MyThread(LPVOID lpThreadParameter)
{
char* p = new char[100];
Sleep(10000000);
return 0;
}
int _tmain(int argc, _TCHAR* argv[])
{
for(int i = 1; i < 100000; ++i)
{
HANDLE hThread = CreateThread(0, 0, MyThread, 0, 0, 0);
if (!hThread)
{
printf("Maximum threads: %d\n", i);
assert(hThread);
break;
}
CloseHandle(hThread);
}
return 0;
}