public class SleepSort {
public static void main(String[] args) {
int[] nums = new int[]{1, 2, 34, 4, 45, 56};
sleepSort(nums);
}
public static void sleepSort(int[] nums) {
for (int i = 0; i < nums.length; i++) {
final int num = nums[i];
new Thread(() -> {
try {
Thread.sleep(num);
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println(num);
}).start();
}
}
}
数据结构和算法——睡眠排序
![](https://img-home.csdnimg.cn/images/20240711042549.png)