Created
June 24, 2022 14:13
-
-
Save racecraftr/7185c3d904e491fde2cf8a0b2e778152 to your computer and use it in GitHub Desktop.
Day 18 of the Useless Java series.
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
package UselessJava.Day18; | |
public class Day18 { | |
public String detectCosmicRay(){ | |
final String[] comments = {"Why are you still here?", | |
"Most systems automatically fix errors caused by cosmic rays.", | |
"This is so stupid.", | |
"Based off of a reddit post by u/TripplerX.", | |
"I did nawt kill her, I did naaawt! Oh hai Mark.", | |
"The cheese stands alone, so sad :(", | |
"???", | |
"Why are we still here... just to suffer..."}; | |
Thread t = new Thread(() -> { | |
while(true) { | |
try { | |
System.out.println(comments[(int) (Math.random() * comments.length)]); | |
Thread.sleep(3000); | |
} | |
catch(InterruptedException e) { | |
throw new RuntimeException(e); | |
} | |
} | |
} | |
); | |
t.start(); | |
boolean b = true; | |
while (b){ | |
} | |
t.interrupt(); | |
return "Cosmic ray detected"; | |
} | |
} | |
class Main{ | |
public static void main(String[] args) { | |
Day18 d = new Day18(); | |
System.out.println(d.detectCosmicRay()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment