当前位置:网站首页>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.
边栏推荐
- SVG大鱼吃小鱼动画js特效
- Embedded Systems: Basic Timers
- [Structural Internal Power Cultivation] Structural Realization Stages (2)
- 唤醒手腕 - 微信小程序、QQ小程序、抖音小程序学习笔记(更新中)
- 每一个女孩曾经都是一个没有泪的天使
- Nn. Unfold and nn. The fold
- Fiddler工具讲解
- 【 LeetCode 】 235. A binary search tree in recent common ancestor
- 基于多块信息提取和马氏距离的k近邻故障监测
- 国家强制性灯具安全标准GB7000.1-2015
猜你喜欢
随机推荐
MVCC of Google's Fragmented Notes (Draft)
作为一个男人必须明白的22个道理
奇怪的Access错误
MM上街前的折腾(有趣)
MobileNetV1架构解析
餐饮大单品「真香」,却没有穿透周期的能力
Jmeter永久设置中文界面
[Structural Internal Power Cultivation] Structural Realization Stages (2)
pnpm 是凭什么对 npm 和 yarn 降维打击的
在ASP控制数字及字母输入
漂亮MM和普通MM的区别
2006年星座运势全解-巨蟹
Data source object management Druid and c3p0
JS实现从照片中裁切自已的肖像
Basic introduction of stack and queue and C language implementation of functions such as creation, destruction, entry and exit, counting the number of elements, viewing elements, etc., as well as stac
【深度学习实践(一)】安装TensorFlow
U++ UE4官方文档课后作业
微信 小程序 之PC端 不支持 wx.previewMedia 方法 故用自定义轮播图进行 模拟照片视频的播放
Adb authorization process analysis
[Structure internal power practice] Structure memory alignment (1)









