Skip to content

Instantly share code, notes, and snippets.

@Tomotoes
Last active August 18, 2019 07:45
Show Gist options
  • Save Tomotoes/ac12e411e6413f872d530aaf24cd5a2d to your computer and use it in GitHub Desktop.
Save Tomotoes/ac12e411e6413f872d530aaf24cd5a2d to your computer and use it in GitHub Desktop.
Legendary sleep sort
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