我以为我知道 beginthread 中的堆栈大小参数是什么意思。所以我的问题是:为什么这行得通?
#include <iostream>
#include <process.h>
using namespace std;
void huge_stack(int a, int b, int c, int d)
{
int i[100000] = {0};
cout << a << b << c << d << i[12333] << endl;
}
bool done = false;
void thread(void* p)
{
huge_stack(1,2,3,4);
done = true;
}
int main()
{
_beginthread(thread, 10, nullptr);
while(!done) {}
return 0;
}
我确保我在调试模式下构建,因此不会优化调用和数组。