Nov 3, 2018

What should be paid attention to in asynchronous programming

Exceptions should be handled inside the asynchronous methods. You also should note the difference between synchronous and asynchronous exceptions. the former implies exceptions that would occur at a particular program statement every time the program is executed; asynchronous exceptions are those that are much more difficult to handle and can occur anywhere in your code.

Constructors cannot be asynchronous and asynchronous methods should not be called inside a constructor. Asynchrony is particularly useful when the tasks executed asynchronously are independent from one another. You should not use asynchrony when the invoking task depends on the called task (asynchronous method) for it to proceed.

To facilitate testing, you should separate or isolate functionality from multithreading in your code.