给线程命名

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);
}
}
原文地址:https://www.cnblogs.com/herosoft/p/9473493.html