想使用匿名的方式创建线程、设置线程名称和运行线程写在同一行代码请问如何做到?
2条回答 默认 最新
牧子与羊 2020-11-10 09:42关注public static void main(String[] args) { new Thread(Thread.currentThread().getThreadGroup(), () -> { System.out.println("to do some things"); }, "thread-name").start(); }本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报