线程属于一次性消耗品,在执行完 run() 方法之后线程便会正常结束了,线程结束后便会销毁,不能再次 start,只能重新建立新的线程对象。
public static void main(String[] args) {
Thread wise = new Thread(() -> System.out.println("wise"));
wise.start();
wise.start();
}
Exception in thread "main" java.lang.IllegalThreadStateException
at java.lang.Thread.start(Thread.java:708)
at org.example.date20210722.Main.main(Main.java:8)
wise