Advertisement
BenTibnam

CPU Stress Test

Aug 20th, 2023
839
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.76 KB | Software | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Threading;
  4. using System.Threading.Tasks;
  5.  
  6. namespace CPUStress {
  7.     class Program {
  8.         static void Main(string[] args) {
  9.             Enumerable.Range(0, 25000).ToList().ForEach(f => {
  10.                 // Generic Thread
  11.                 Thread thread = new Thread(() => {
  12.                     Console.WriteLine($"Thread Number: {Thread.CurrentThread.ManagedThreadId} started.");
  13.                     Thread.Sleep(1000);
  14.                     for (int i = 0; i < Int32.MaxValue; i++) ;
  15.                     Console.WriteLine($"Thread Number: {Thread.CurrentThread.ManagedThreadId} ended.");
  16.                 });
  17.  
  18.                 thread.Start();
  19.             });
  20.  
  21.             Console.ReadKey();
  22.         }
  23.     }
  24. }
Tags: test cpu stress
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement