public static void main(String[] args) { ExecutorService executorService = Executors.newCachedThreadPool(); executorService.execute(new Runnable() { @Override public void run() { System.out.println(Thread.currentThread().getName()+"-我是子线程"); } }); }
lambda表达式方式
public static void main(String[] args) { ExecutorService executorService = Executors.newCachedThreadPool(); executorService.execute(() -> System.out.println(Thread.currentThread().getName()+"-我是子线程")); }
标签:currentThread,方式,创建,void,System,线程,executorService,public From: https://www.cnblogs.com/ixtao/p/17455213.html