在具有相同线程池的不同 class 上异步 Spring Boot

Async on different class with same Threadpool SpringBoot

我配置了 1 个线程池 @Async(value="pool_1")。现在我想在不同的 classes 中使用这个线程池,所以我将 @Async(value="pool_1") 放在我的 2 个不同的 class 之上。我只想得到确认,就像它不会创建 2 个单独的线程池一样。 就像我将池大小设置为 500 个线程一样,将相同的异步放在 2 个不同的 class 上,不会将池大小设置为 1000,对吗? 此外,这些线程将 SHARED 而不是 divided 2 classes right

Like I have set my pool size to 500 threads, putting same async on 2 different class, won't set pool size to 1000 right?

所有使用 @Async(value="pool_1") 的方法都将使用相同的单线程池(即您配置的大小为 500 的线程池)。

Also these threads will be SHARED and not be divided between 2 classes right

没有预先为每个方法分配固定数量的线程(如果这是您要求的)。