글쓴 사람
정성태 (techsharer at outlook.com)
홈페이지
첨부 파일
(연관된 글이 2개 있습니다.)
C# - CPU 100% 부하 주는 프로그램
가끔 필요할 때가 있군요. ^^ 혹시 다른 분들도 필요하실지 몰라 올려놓습니다. ^^
코드는 다음과 같이 간단하게 작성할 수 있고,
using System;
using System.Collections.Generic;
using System.Threading;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
for (int i = 0; i < Environment.ProcessorCount; i ++)
{
Thread t1 = new Thread(threadFunc);
t1.IsBackground = true;
t1.Start();
}
Console.WriteLine("Press ENTER key to exit...");
Console.ReadLine();
}
private static void threadFunc()
{
while (true)
{
}
}
}
}
빌드하면 되는데,
첨부 파일에 소스 코드와 함께 .exe 빌드된 것까지 올렸으니 그냥 실행하시면 됩니다. CPU가 몇 개든, 다음과 같이
100% 사용률을 보입니다.
[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]
[연관 글]
... 196 [197]
... 196 [197]