Advertisement
ice-pro

wtf?

Oct 16th, 2017
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.68 KB | None | 0 0
  1. using System;
  2. using System.Threading;
  3.  
  4. namespace GC_Block {
  5.     class Program {
  6.         public static void Main(string[] args) {
  7.             while (true) {
  8.                 var gabrabe = new Garbage();
  9.                 Console.WriteLine(gabrabe);
  10.             }
  11.         }
  12.     }
  13.  
  14.     class Garbage {
  15.         private string garbage = "garbage";
  16.  
  17.         public Garbage() {
  18.             Console.WriteLine("Garbage created...");
  19.         }
  20.        
  21.         ~Garbage() {
  22.             Console.WriteLine("GC thread blocked");
  23.             Thread.Sleep(TimeSpan.FromHours(1));
  24.         }
  25.  
  26.         public override string ToString() {
  27.             return "Garbage";
  28.         }
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement