One: Look at the program
Second: Phenomenon
when the program starts, Button1 will automatically swipe to the right three times, but when you click Button2, the Button1 move will pause for 5 seconds.
Three: Thread blocking:
When an application is launched, the Android system will create a main thread for the app. This thread is very important, it is responsible for rendering the view, distributing the event to the response listener and executing, polling the interface for listening. Therefore, it is generally called the "UI thread".
The Android system does not give the application multiple element components to build multiple threads to execute. Multiple view components in an activity are running in the same UI thread. As a result, the execution of listeners for multiple view components may affect each other.
For example, when you perform time-consuming operations in the UI thread, such as accessing the network, accessing the database, and so on. Will cause the UI thread to block. When the UI thread is blocked, the screen will appear stuck. This makes the user experience very poor. When the thread is blocked for more than 5 seconds, the Android system may intervene, and a popup dialog asks whether to close the application.
Android Learning: UI thread Blocking