当我们使用createthread函数创建cpu * 2线程时,却发生了一个线程退出,因为GetQueuedCompletionStatus函数返回错误 [英] when we use createthread function to create cpu * 2 thread,but occured one thread exit because GetQueuedCompletionStatus function return error

查看:230
本文介绍了当我们使用createthread函数创建cpu * 2线程时,却发生了一个线程退出,因为GetQueuedCompletionStatus函数返回错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,如果发生这种情况,程序仍然可以运行,但现在,有多少线程还活着?

如果有两个cpu,生成四个线程,现在,三个?

so,if occured that,program can running still,but now,how many thread alive?
if has two cpu,generated four threads,now,three?

推荐答案

如果你有一个线程池和一个线程退出 - 这可能是一个设计缺陷。线程执行的工作不应导致线程退出。通常它会做一些工作并返回池中等待更多工作。



如果GetQueuedCompletionStatus返回错误 - 编写代码来处理错误并允许线程返回等待更多工作的空闲状态。
If you have a pool of threads and one thread exits - that's likely a design flaw. The work performed by the thread should not cause the thread exit. Normally it does some work and returns to the pool to wait for more work.

If GetQueuedCompletionStatus returns an error - write code to handle the error and allow the thread to return to an idle state waiting for more work.


这篇关于当我们使用createthread函数创建cpu * 2线程时,却发生了一个线程退出,因为GetQueuedCompletionStatus函数返回错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆