Home > Software design >  Async on different class with same Threadpool SpringBoot
Async on different class with same Threadpool SpringBoot

Time:10-07

I have configured 1 threadpool @Async(value="pool_1"). now I want to use this threadpool in different classes, so I put @Async(value="pool_1") above my 2 different class. I just want to get confirmation like it won't create 2 seperate pool of thread. 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? Also these threads will be SHARED and not be divided between 2 classes right

CodePudding user response:

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?

All methods using @Async(value="pool_1") will use the same single thread pool (i.e. the one you configured with size 500).

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

There is no upfront allocation of a fixed number of threads to each method (if that is what you asked for).

  • Related