C ++多线程执行速度减慢 [英] C++ Multi-Thread Execution Speed Slow-Down

查看:779
本文介绍了C ++多线程执行速度减慢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在写一个多线程c ++应用程序。当线程A的执行计算量很大时,它会减慢线程B,C和D.我如何防止这种情况?

I am writing a multi-threaded c++ application. When thread A has a very computationally expensive operation to perform, it slows down threads B, C, and D. How can I prevent this?

推荐答案

在Windows上,您可以使用 Sleep(0)来释放剩余的时间表,以等待其他线程。

On windows you can use Sleep(0) to release the remainder of your timeslice for other threads that are waiting.

这篇关于C ++多线程执行速度减慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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