Created
June 16, 2011 10:26
-
-
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.
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
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(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
$ java SleepSort 3 8 1 6 2 4 6 4
1
2
3
4
4
6
6
8