Posts Tagged ‘sleep sort’
Sleep Sort
Zabawny algorytm sortujący:
public class SleepSort {
public static void main(String[] args) {
for (final String arg : args) {
new Thread() {
public void run() {
try {
Thread.sleep(Integer.parseInt(arg));
} catch (Exception e) {
}
System.out.print(arg + " ");
}
}.start();
}
}
}
<barista@javaczyherbata.pl> java SleepSort 23 2 45 9 15 10 87 21 100 34 45 18 2 9 10 15 18 21 23 34 45 45 87 100