Skip to content

Instantly share code, notes, and snippets.

@elefevre
Created June 16, 2011 10:26
Show Gist options
  • Save elefevre/1029014 to your computer and use it in GitHub Desktop.
Save elefevre/1029014 to your computer and use it in GitHub Desktop.
My attempt at SleepSort in Java. See http://dis.4chan.org/read/prog/1295544154 for original implementation in bash.
public class SleepSort {
private static Thread f(final int value) {
return new Thread(new Runnable() {
@Override
public void run() {
try {
Thread.sleep(value);
} catch (InterruptedException e) {
}
System.out.println(value);
}
});
}
public static void main(String[] args) {
for (String value : args) {
f(Integer.parseInt(value)).start();
}
}
}
@elefevre
Copy link
Author

$ java SleepSort 3 8 1 6 2 4 6 4
1
2
3
4
4
6
6
8

@salemhilal
Copy link

Heh, nice job. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment