创建多线程

发布于 2024-12-05 00:57:11 字数 590 浏览 0 评论 0原文

我在vs2008中使用多线程方法,使用c++语言。当我使用 _beginthreadex 函数时,出现以下错误:

error C2664: '_beginthreadex' : cannot convert parameter 3 from 'unsigned int
(__stdcall *)(void *)' to 'unsigned int (__stdcall *)(void *)'

ps: 我在 threadFunc 上使用模板,如下所示:

template; 无符号 int WINAPI 关闭Reconstruction_ThreadFunc(void* pvPara) {...}

,然后我创建线程

_beginthreadex(NULL,0,closingReconstruction_ThreadFunc<T>,(PVOID)(tPara+i),0,NULL)

,所以我得到这个错误,当然,如果我删除模板,它可以工作,但我需要使用模板,有什么方法可以解决这个问题。

I use Multi-thread method in vs2008 ,use c++ language. when I use _beginthreadex function, I got the follow error:

error C2664: '_beginthreadex' : cannot convert parameter 3 from 'unsigned int
(__stdcall *)(void *)' to 'unsigned int (__stdcall *)(void *)'

ps: I use the template on the threadFunc like this:

template<class T>
unsigned int WINAPI closingReconstruction_ThreadFunc(void* pvPara)
{...}

,and then i creat the thread

_beginthreadex(NULL,0,closingReconstruction_ThreadFunc<T>,(PVOID)(tPara+i),0,NULL)

so i get this error , of course , if I remove the template ,it can be work,but i need to use template, are there any methods to solve this.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

隔岸观火 2024-12-12 00:57:11

您忘记提及前面的错误消息,

错误 C2065:“T”:未声明的标识符

让我声明一下,首先查看第一条错误消息通常是一个好主意。

干杯&呵呵,,

You forgot to mention the immediately preceding error message,

error C2065: 'T' : undeclared identifier

Let me just state that looking at the first error message first, is generally a good idea.

Cheers & hth.,

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文