“[http-bio-8080-exec-494] [ERROR]”中exec之后的数字是什么意思?

What is meaning of the number after exec in "[http-bio-8080-exec-494] [ERROR]"?

在调查遗留 Java Spring 部署在 tomcat 7 上的 Maven 项目时,日志如下所述 -

2018-08-29 18:16:42:471 +0600 [http-bio-8080-exec-494] [ERROR]

要求在

之后揭开数字的神秘面纱

exec-

那么基本就是"exec"的意思了? 对于上述情况,这是 494

这是tomcat中的线程池生成的线程ID号。真正的问题是不同的,这是一个内部信息,它的价值是什么,现在你知道了吗?我假设接近于零...

这很可能是自定义生成的线程 ID ThreadFactory,就像:

Executor executor = Executors.newFixedThreadPool(4, new ThreadFactory() {
    AtomicInteger threadId = new AtomicInteger(0);
    @Override
    public Thread newThread(Runnable r) {
        return new Thread(r, "http-bio-8080-exec-" + threadId.getAndIncrement());   // custom a thread factory 
    }
});

IntStream.range(0, 10).forEach(value -> {
    executor.execute(() -> {    
        System.out.println(Thread.currentThread().getName());   // print thread name
        try {
            Thread.sleep(100);
        } catch (Exception e) {

        }
    });
});

输出:

http-bio-8080-exec-0
http-bio-8080-exec-1
http-bio-8080-exec-2
http-bio-8080-exec-3
http-bio-8080-exec-0
http-bio-8080-exec-3
http-bio-8080-exec-1
http-bio-8080-exec-2
http-bio-8080-exec-0
http-bio-8080-exec-3