当前位置:网站首页>Thinking after writing a code with a very high CPU usage
Thinking after writing a code with a very high CPU usage
2022-08-05 08:08:00 【code beans】
1 If you write an infinite loop without any delay, the CPU usage will skyrocket.
2 Task.Delay() is an asynchronous delay, which cannot be delayed when written in synchronous code.
3 Thread.Sleep(0) does not really want the thread to be suspended for 0 milliseconds. The meaning is that the current thread calling Thread.Sleep(0) is indeed frozen this time, giving other threads a chance to execute first.Thread.Sleep(0) means that your thread temporarily gives up the cpu, that is, releases some unused time slices for use by other threads or processes, which is equivalent to an abdication action.
4 Writing a Thread.Sleep(0) in an infinite loop will not cause the CPU usage to soar.
边栏推荐
- 奇怪的Access错误
- CROS和JSONP配置
- php向mysql写入数据失败
- 【深度学习实践(一)】安装TensorFlow
- Green Apple Forum reopens
- RedisTemplate: error template not initialized; call afterPropertiesSet() before using it
- 请问my sql如何把两个表的内容集合在一起啊?
- 【 LeetCode 】 235. A binary search tree in recent common ancestor
- Access Denied: "microsoft.web.ui.webcontrols" workaround
- Long-term recruitment embedded development-Shenzhen Baoan
猜你喜欢
随机推荐
真正爱你的女人是这样的
v-if/v-else determines whether to display according to the calculation
Adb 授权过程分析
SQL SERVER关于主从表触发器设计
Mysql 死锁和死锁的解决方案
线性代数对角化
字符串提取 中文、英文、数字
browserslist 选项的目的是什么?
iptables实现网络限制下ntp自定义端口同步时间
谷歌零碎笔记之MVCC(草稿)
Discourse 清理存储空间的方法
监听浏览器刷新操作
ps怎么拼图,自学ps软件photoshop2022,PS制作拼图效果
Illegal key size 报错问题
VXE-Table融合多语言
Codeforce 8.1-8.7做题记录
数据源对象管理Druid和c3p0
moment的使用
[Untitled] Long-term recruitment of hardware engineers-Shenzhen Baoan
MongoDB 语法大全






![[Structural Internal Power Cultivation] Structural Realization Stages (2)](/img/eb/c80e12edbf4a411227be7e33096ed3.png)


