thi*_*not 1 c++ windows parameters multithreading beginthreadex
是否可以将多个参数传递给beginthreadex?
我知道我可以创建一个类或结构,但如果我有不相关的数据片段,我不想将它们组合成一个类或结构呢?
Boost库似乎允许多个参数,但我如何为标准c ++ _beginThreadEx执行多个参数?
#include <iostream>
#include <process.h>
unsigned __stdcall myThread(void *data)
{
//C:\dev\default threads\_threads.cpp|6|error: invalid conversion from 'int*' to 'int' [-fpermissive]|
int *x = static_cast<int*>(data);
//int *x = (int*)data;
std::cout << "Hello World! " << x;
}
int main()
{
int x = 10;
_beginthreadex(NULL, 0, myThread, &x, 0, NULL);
while(true);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3350 次 |
| 最近记录: |