package service;

import java.util.stream.IntStream;

/**
* @description: 给线程命名
* @author:
* @create:
**/

public class NamedThreads {
public static final String PREFIX = "NO-";

public static void main(String[] args) {
IntStream.range(0, 5).boxed().map(NamedThreads::createThread).forEach(Thread::start);
}

private static Thread createThread(final int intName){
return new Thread(() -> System.out.println(Thread.currentThread().getName()),
PREFIX + intName);
}
}

相关文章:

  • 2022-02-15
  • 2021-10-30
  • 2021-11-17
  • 2022-01-03
  • 2021-12-18
  • 2021-05-12
  • 2021-09-08
猜你喜欢
  • 2022-12-23
  • 2021-10-29
  • 2022-12-23
  • 2021-06-25
  • 2022-12-23
  • 2021-08-30
  • 2022-12-23
相关资源
相似解决方案