# Start & Run
start和run方法的区别就是,start具体调用由底层去执行,而run还是由调用者去执行,run并不是异步
# start
@Slf4j
public class Demo {
public static void main(String[] args) throws ExecutionException, InterruptedException {
log.info("main run..");
new Thread(() -> log.info("thread run..")).start();
}
}
//22:46:47.637 [main] INFO com.gao.Demo - main run..
//22:46:47.689 [Thread-0] INFO com.gao.Demo - thread run..
# run
@Slf4j
public class Demo {
public static void main(String[] args) throws ExecutionException, InterruptedException {
log.info("main run..");
new Thread(() -> log.info("thread run..")).run();
}
}
//22:46:29.560 [main] INFO com.gao.Demo - main run..
//22:46:29.609 [main] INFO com.gao.Demo - thread run..