SpringBoot asynchronous call receiving method and a return value

The project is sure to encounter an asynchronous method call other scenarios, such as a computing process, need to calculate the value of a number of indicators, but each index calculation efficiency at different rates, if the synchronization execution, time to run this process All indicators are calculated sum of the times. such as:

Method A: Calcd index x, y index, the index z, wherein x is calculated metrics need 1s, y calculated metrics need 2s, z indices need 3s. A final method is to complete the implementation of 5s.

Now asynchronous way to optimize it

A method of asynchronous call to Method B, Method C, Method D, method B, Method C, Method D index x, index y, z are respectively calculated value of the index, then the final A time of executing the method is 3s.

Guess you like

Origin www.cnblogs.com/DDgougou/p/11964425.html