Start Android
1. Review threading Concepts in Java
1) Two implementations of threads 2) thread life cycle 3) multithreading synchronization (multiple threads accessing the same resource, in the same) 2, Mainthread and worker Thread 1) UI-related code is mainthread 2) other code is workerthread (not allowed to operate Ui,progressbar) 3) in an application process Sequence, the main thread is usually used to receive input from the user, and the results of the operation are fed back to the user (i.e. the main thread cannot be blocked) for some operations that may cause blocking and must be placed in the worker thread 3. Thread Usage in Android 4. What is Handler 5, Handler, Looper and Messgequeue Basic principles (can be used to implement communication between threads) These three mates complete Message Queuing 1) First, generate a class (inheritance Handler) and create a reference to the object of the Handler class Myhandle R (name customizable) 2) The new Firsthandler object is then assigned a reference to the object of the handler class MyHandler (upward transformation); 3) Message SMG = Myhandler.obtainmessage (); Use the Obtainmessage method of the MyHandler object to create a Message object 4) to manipulate the Msg object, with MSG attached to the message, such as: Msg.what = 100; 5) Call Myhandler.sendmessage (msg); method, put MSG this message object into the message Queue 6) Looper will remove the message from the message Queue 7) Looper will find the handler object corresponding to the Message object (here is MyHandler) 8) The last Looper will invoke the Handlermessage (message msg) of the MyHandler object; method for processing the Message object 6, through handler to achieve inter-thread communication 7, in the main thread to achieve handler Handlermessage () method 8, in the worker thread through the handler Send message 1) Prepare Looper object thread of the class of the Run method, call Looper.prepare (); 2) in worker thread, generate handler Object handler = new Handler () {public void Handlemessage (Message msg) {}} 3) Send message in Mainthread