SpringBoot based on an asynchronous call annotation @Async use of threads

@Async Description: In Spring, the method @Async based tagging, called asynchronous methods; these methods when executed, will be executed in a separate thread, the caller without waiting for its completion, you can continue other operations.

@Async Usage: @Async added to the method

Transaction processing @Async call: The original link: https: //blog.csdn.net/fwk19840301/article/details/90082867

    In the method @Async marked, but also for the @Transactional been labeled; when they call database operation, the control transaction management will not produce, the reason lies in its operation is based on asynchronous processing.

     How to add that the transaction manager to do these operations? The method requires transaction management operations can be placed inside the asynchronous method, add @Transactional on internal method is called.

    For example: Method A, using @ Async / @ Transactional to mark, but can not generate transaction control purposes.

                Method B, used to mark the @Async, B calls the object C, D, C / D are respectively denoted by the @Transactional made, transaction control can be realized.

Please refer to the original link : https://www.cnblogs.com/jpfss/p/10273129.html

Guess you like

Origin www.cnblogs.com/gjq1126-web/p/12190432.html