首页 新闻 会员 周边 捐助

为什么cpu的暂用率不是百分之百

0
[已关闭问题]
<DIV class=cnblogs_code><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #0000ff">using</SPAN><SPAN style="COLOR: #000000">&nbsp;System;<BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">using</SPAN><SPAN style="COLOR: #000000">&nbsp;System.Collections.Generic;<BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">using</SPAN><SPAN style="COLOR: #000000">&nbsp;System.Linq;<BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">using</SPAN><SPAN style="COLOR: #000000">&nbsp;System.Text;<BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">using</SPAN><SPAN style="COLOR: #000000">&nbsp;System.Threading;<BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top><BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">namespace</SPAN><SPAN style="COLOR: #000000">&nbsp;test<BR><IMG id=Codehighlighter1_126_604_Open_Image onclick="this.style.display='none'; document.getElementById('Codehighlighter1_126_604_Open_Text').style.display='none'; document.getElementById('Codehighlighter1_126_604_Closed_Image').style.display='inline'; document.getElementById('Codehighlighter1_126_604_Closed_Text').style.display='inline';" src="http://space.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_126_604_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; document.getElementById('Codehighlighter1_126_604_Closed_Text').style.display='none'; document.getElementById('Codehighlighter1_126_604_Open_Image').style.display='inline'; document.getElementById('Codehighlighter1_126_604_Open_Text').style.display='inline';" src="http://space.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN id=Codehighlighter1_126_604_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://space.cnblogs.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_126_604_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">class</SPAN><SPAN style="COLOR: #000000">&nbsp;Program3<BR><IMG id=Codehighlighter1_151_602_Open_Image onclick="this.style.display='none'; document.getElementById('Codehighlighter1_151_602_Open_Text').style.display='none'; document.getElementById('Codehighlighter1_151_602_Closed_Image').style.display='inline'; document.getElementById('Codehighlighter1_151_602_Closed_Text').style.display='inline';" src="http://space.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_151_602_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; document.getElementById('Codehighlighter1_151_602_Closed_Text').style.display='none'; document.getElementById('Codehighlighter1_151_602_Open_Image').style.display='inline'; document.getElementById('Codehighlighter1_151_602_Open_Text').style.display='inline';" src="http://space.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN id=Codehighlighter1_151_602_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://space.cnblogs.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_151_602_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">void</SPAN><SPAN style="COLOR: #000000">&nbsp;Main(</SPAN><SPAN style="COLOR: #0000ff">string</SPAN><SPAN style="COLOR: #000000">[]&nbsp;args)<BR><IMG id=Codehighlighter1_201_365_Open_Image onclick="this.style.display='none'; document.getElementById('Codehighlighter1_201_365_Open_Text').style.display='none'; document.getElementById('Codehighlighter1_201_365_Closed_Image').style.display='inline'; document.getElementById('Codehighlighter1_201_365_Closed_Text').style.display='inline';" src="http://space.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_201_365_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; document.getElementById('Codehighlighter1_201_365_Closed_Text').style.display='none'; document.getElementById('Codehighlighter1_201_365_Open_Image').style.display='inline'; document.getElementById('Codehighlighter1_201_365_Open_Text').style.display='inline';" src="http://space.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN id=Codehighlighter1_201_365_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://space.cnblogs.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_201_365_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Thread&nbsp;thd</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000">&nbsp;Thread(</SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000">&nbsp;ThreadStart(test));<BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;thd.IsBackground&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">false</SPAN><SPAN style="COLOR: #000000">;<BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;thd.Start();<BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Console.ReadLine();<BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top><BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">private</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">void</SPAN><SPAN style="COLOR: #000000">&nbsp;test()<BR><IMG id=Codehighlighter1_410_596_Open_Image onclick="this.style.display='none'; document.getElementById('Codehighlighter1_410_596_Open_Text').style.display='none'; document.getElementById('Codehighlighter1_410_596_Closed_Image').style.display='inline'; document.getElementById('Codehighlighter1_410_596_Closed_Text').style.display='inline';" src="http://space.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_410_596_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; document.getElementById('Codehighlighter1_410_596_Closed_Text').style.display='none'; document.getElementById('Codehighlighter1_410_596_Open_Image').style.display='inline'; document.getElementById('Codehighlighter1_410_596_Open_Text').style.display='inline';" src="http://space.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN id=Codehighlighter1_410_596_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://space.cnblogs.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_410_596_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine(</SPAN><SPAN style="COLOR: #800000">"</SPAN><SPAN style="COLOR: #800000">exec&nbsp;back&nbsp;thread<IMG src="http://space.cnblogs.com/images/dot.gif">.</SPAN><SPAN style="COLOR: #800000">"</SPAN><SPAN style="COLOR: #000000">);<BR><IMG id=Codehighlighter1_490_586_Open_Image onclick="this.style.display='none'; document.getElementById('Codehighlighter1_490_586_Open_Text').style.display='none'; document.getElementById('Codehighlighter1_490_586_Closed_Image').style.display='inline'; document.getElementById('Codehighlighter1_490_586_Closed_Text').style.display='inline';" src="http://space.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_490_586_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; document.getElementById('Codehighlighter1_490_586_Closed_Text').style.display='none'; document.getElementById('Codehighlighter1_490_586_Open_Image').style.display='inline'; document.getElementById('Codehighlighter1_490_586_Open_Text').style.display='inline';" src="http://space.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">while</SPAN><SPAN style="COLOR: #000000">(</SPAN><SPAN style="COLOR: #0000ff">true</SPAN><SPAN style="COLOR: #000000">)</SPAN><SPAN id=Codehighlighter1_490_586_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://space.cnblogs.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_490_586_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">Console.WriteLine("aaaa");</SPAN><SPAN style="COLOR: #008000"><BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Thread.Sleep(</SPAN><SPAN style="COLOR: #800080">1000</SPAN><SPAN style="COLOR: #000000">);<BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top>我写了一个死循环,同时测了线程是backgroud和front的情况,但是cpu使用率还是很低,怎么回事啊</SPAN></DIV>
lexus的主页 lexus | 初学一级 | 园豆:0
提问于:2008-07-25 22:41
< >
分享
其他回答(3)
0
你在里面点东西比如做点乘法试试~~~
沙加 | 园豆:3680 (老鸟四级) | 2008-07-26 09:19
0
设为后台线程与非后台线程的主要区别是:如果是后台线程,调用线程结束,后台线程也结束(不管有没有执行完成),如果不是后台线程,调用线程结束,它并不结束,直到它执行完成后才结束. 另外:不管是不是后台线程它们都不是同一个线程,它们是父子关系. 一个程序中可以有多个后台线程.
侯垒 | 园豆:3435 (老鸟四级) | 2008-07-26 11:24
0
去掉这一句: Thread.Sleep(1000); 你去睡觉了,还能占着CPU?
deerchao | 园豆:8367 (大侠五级) | 2008-07-26 17:47
0
Thread.Sleep(1000); 会让出CPU时间片, 可以随便做点什么 东西 (什么都不做的话,应该也会很费CPU) 另外,一个问题,就是, 如果你是双核或以上的CPU, 你永远不可能100% 最多是1/CPU 内核个数 ---- 看到你说了你是双核 那你肯定不会是100% 了 建议你不要看那个百分比 去看那个人物管理器里的 CPU使用率 图标 或者找找第三方工具试试 如果你非要让CPU100%,的话 1,你开2个程序实例 2,使用 并行化计算类库, 处理
G yc {Son of VB.NET} | 园豆:2006 (老鸟四级) | 2008-07-26 18:06
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册