Created
September 23, 2017 08:42
-
-
Save kabutz/f971ef61f0eb784dc2376ad4f3ad7ea5 to your computer and use it in GitHub Desktop.
Three cheers (or more) for Java 9 release!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Compile and run in Java 9. Then compile and run in Java 8 and 9. Enjoy your new JDK :-D | |
public class Java9AtLast { | |
public static void hiphip(int cheers) { | |
try { | |
hiphip(cheers + 1); | |
} catch(StackOverflowError er) { | |
System.out.println("hooray x " + cheers); | |
} | |
} | |
public static void main(String... args) { | |
hiphip(0); | |
} | |
} |
Fortunately synchronized is fairly robust in this way ...
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can produce some marvelous hacks with StackOverflowError - for example, make threads die without releasing their locks ... :-)