package com.sleep;
public class Main {
public static void main(String[] args) {
int[] arr = {1.9.2.8.8.3.6.4.5.7};
for (int i1 : arr) {
newSleepThread(i1).start(); }}}class SleepThread extends Thread {
private int number;
SleepThread(int number) {
this.number = number;
}
@Override
public void run(a) {
try {
Thread.sleep(number * 500);
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println(number + ""); }}Copy the code
Here *500 milliseconds, so you can see what’s going on, and if it’s a little bit bigger, well… Just as the headline says
Sleep sequencing is fun, but of no practical value, and has few drawbacks…
Not to mention the resource consumption of starting a large number of threads, elements with close values may not be printed in order, and threads may sleep longer than a month once large elements are encountered…