1 asynctaskImplementation principle,Applicable advantages and disadvantages
Asynctask is a lightweight asynchronous class provided by Android. It can inherit asynctask directly and implement asynchronous operations in the class,AndProvide interface feedback to the currentAsynchronous execution degree(Ui progress update can be implemented through the interface), and finally the execution result is fed back to the main UI thread.
Advantages:
L simple and fast
L process controllable
Disadvantages:
L it becomes complicated when multiple asynchronous operations and UI changes are required.
2 HandlerPrinciples and advantages of asynchronous implementation
When handler is implemented asynchronously, it involves four objects: handler, logoff, message, and thread. the asynchronous process is that the main thread starts thread (subthread) à thread (subthread) run and generate message-à logoff to get the message and pass it to handler. the handler gets the message in logoff one by one and changes the UI.
Advantages:
L clear structure and clear Function Definition
L simple and clear for multiple background tasks
Disadvantages:
L when asynchronous processing is performed on a single backendCodeToo many, too complex structure (relative)