29 lines
600 B
Java
29 lines
600 B
Java
|
package thead.thread_5;
|
||
|
|
||
|
import lombok.SneakyThrows;
|
||
|
import lombok.extern.slf4j.Slf4j;
|
||
|
|
||
|
@Slf4j
|
||
|
public class MyThreadTest1 {
|
||
|
public static void main(String[] args) throws InterruptedException {
|
||
|
|
||
|
Thread thread = new Thread("t1") {
|
||
|
@SneakyThrows
|
||
|
@Override
|
||
|
public void run() {
|
||
|
super.run();
|
||
|
Thread.sleep(2000);
|
||
|
}
|
||
|
};
|
||
|
|
||
|
thread.start();
|
||
|
log.info("t1:{}", thread.getState());
|
||
|
|
||
|
Thread.sleep(500);
|
||
|
log.info("t1-2:{}", thread.getState());
|
||
|
|
||
|
thread.setDaemon(true);
|
||
|
}
|
||
|
}
|
||
|
|