Hello,

Is there any official way to initialize 'singleton' beans using multiple threads?

Imagine situation where I have n instances of BeanA (with different parameters) and BeanB which is expecting to get all of them during construction. At the moment, BeanA-1 till BeanA-n are constructed one after another, even if they are completely independent of each other.

I can probably do it manually, by spawning new thread doing the heavy work in BeanA constructor or init method, expose future indicating the work done and do a barrier wait on those futures in BeanB. Unfortunately, I will need to expose the 'completion' futures in BeanA api, manage thread pool myself and generally do a lot of stuff framework could do for me.

Is there any official way of doing that through Spring ? Specifying a thread pool/executor somewhere and letting it resolve all 'parallel' beans concurrently, blocking only when necessary because of dependencies? If not, any particular reason why it is not available?