Cod sursa(job #1376309)

Utilizator nita_teddyTeddy Nita nita_teddy Data 5 martie 2015 17:01:52
Problema A+B Scor 0
Compilator java Status done
Runda Arhiva de probleme Marime 0.62 kb
import java.util.concurrent.atomic.AtomicInteger;

public class Main {
  // Not actually necessary for the leak - keeps track of how many Hydras there are, so we know when they're all gone
  public static AtomicInteger count = new AtomicInteger(0);
  public Main() {
    count.incrementAndGet();
  }
  protected void finalize() {
    new Main();
    new Main();
    count.decrementAndGet();
  }

  public static void main(String[] args) throws InterruptedException {
    new Main();
    while (Main.count.get() > 0) {
      // Prevent leaks ;-)
      System.gc();
      System.runFinalization();
    } 
  }
}