Why Thread.Sleep() is so CPU intensive?

后端 未结 4 1847
无人及你
无人及你 2020-12-10 05:36

I have an ASP.NET page with this pseduo code:

while (read)
{
   Response.OutputStream.Write(buffer, 0, buffer.Length);
   Response.Flush();
}
4条回答
  •  星月不相逢
    2020-12-10 06:01

    Its because the thread gets a priority boost every time it yields its time slice. Avoid calling sleep often ( particularly with low values ).

提交回复
热议问题