I have a component A that asynchronously (@Async interface is used) runs the foo() method in component B. However, it may happen that the data in component B is not initialized yet and then foo() does not work correctly. Component A needs to wait for the data in component B to be initialized.
Is there any high-level solution in Spring (I don't want to play directly with threads) that will try to wait for some time to see if component B initializes and if it initializes earlier, can the foo() method run as well? Thread.sleep() works, but it always waits the whole time, which I don't need.