Skip to main content
1 of 2
Arnaud
  • 8.5k
  • 1
  • 39
  • 60

Java

Let's play with Java class loader:

import java.lang.reflect.Field;

public class Loop {
    public static void main(String[] args) throws Exception {
        System.out.println("Let's loop");
        Field field = ClassLoader.class.getDeclaredField("parent");
        field.setAccessible(true);
        field.set(Loop.class.getClassLoader(), Loop.class.getClassLoader());
    
    }
}

This loop is actually so strong you'll have to use a kill -9 to stop it :-)

It uses 100,1% of my Mac's CPU.

100,1% of CPU

You can try to move the System.out at the end of the main function to experiment an alternate funny behavior.

Arnaud
  • 8.5k
  • 1
  • 39
  • 60