关于线程ID会不会重复的有关问题
关于线程ID会不会重复的问题
while(...)
{
CreateThread(...)
}
我用这样一个循环创建了多个线程,要让每个线程的ID都不同,该怎么做?
就是在线程函数里要用到GetCurrentThreadId函数,而且要求每个线程的ID都不同。
------解决方案--------------------
这是MS干的活,LZ不用操心了。
------解决方案--------------------
当然不会一样的,线程的句柄和线程号都是内核资源,不会重复的
------解决方案--------------------
lpIDThread
[out] Long pointer to a 32-bit variable that receives the thread identifier.
If this parameter is NULL, the thread identifier is not returned.
while(...)
{
CreateThread(...)
}
我用这样一个循环创建了多个线程,要让每个线程的ID都不同,该怎么做?
就是在线程函数里要用到GetCurrentThreadId函数,而且要求每个线程的ID都不同。
------解决方案--------------------
这是MS干的活,LZ不用操心了。
------解决方案--------------------
当然不会一样的,线程的句柄和线程号都是内核资源,不会重复的
------解决方案--------------------
lpIDThread
[out] Long pointer to a 32-bit variable that receives the thread identifier.
If this parameter is NULL, the thread identifier is not returned.