How to increase the CPU usage!!!
Have you ever needed to increase the CPU usage..? It can be just done by writing a simple "While" loop. If you write a seperate thread and add a "While" loop even in that thread your CPU usage will be in the range of 90-100%.
Example:
class ThreadTest
{
static void Main()
{
Thread t = new Thread(WriteY);
t.Start();
while (true)
{
//Thread.Sleep(3); If you want the CPU usage in between 60-90%, you can just vary
//sleep time.
Console.Write("x");
}
}
static void WriteY()
{
while (true)
{
Console.Write("y");
}
}
}
Example:
class ThreadTest
{
static void Main()
{
Thread t = new Thread(WriteY);
t.Start();
while (true)
{
//Thread.Sleep(3); If you want the CPU usage in between 60-90%, you can just vary
//sleep time.
Console.Write("x");
}
}
static void WriteY()
{
while (true)
{
Console.Write("y");
}
}
}
Comments
Post a Comment