Last active
August 18, 2019 07:45
-
-
Save Tomotoes/ac12e411e6413f872d530aaf24cd5a2d to your computer and use it in GitHub Desktop.
Legendary sleep sort
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
import java.util.stream.IntStream; | |
public class SleepSort implements Runnable { | |
private int number; | |
private SleepSort(int number) { | |
this.number = number; | |
} | |
public static void main(String[] args) { | |
IntStream.of(102, 338, 65, 946, 23).forEach(n -> new Thread(new SleepSort(n)).start()); | |
} | |
@Override | |
public void run() { | |
try { | |
Thread.sleep(this.number); | |
System.out.println(this.number); | |
} catch (InterruptedException e) { | |
e.printStackTrace(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment