I. handler is a class provided by the Android operating system.
A queue is a (first-in-first-out) data structure.
2. runable updatethread = new runable () {}; // write the operation to be executed in the run method of the thread object
Handler handler = new handler (); // create a thread object
Handler. Post (updatethread); // call the post method of handler and add the thread object of the thread to be executed to the queue.
Handler. postdelayed (updatethread, 3000); // execute the postdelayed or POST method inside the run Method
3. Bar. setvisibility (view. Visible); // you can specify that the progress bar is visible.
Runnable updatethread = new runable () {}// the Thread class is declared using an anonymous internal class.
Message MSG = updatebarhandler. obtainmessage (); // get a message object. The message class is provided by the Android operating system.
MSG. arg1 = I; // set the arg1 parameter of the MSG object to I and use the two member variables arg1 and agr2 to transmit messages. The advantage is that the system consumes less
Thread. Sleep (1000); // sets the current thread to sleep for one second.
Updatabarhandler. sendmessage (MSG); // Add the MSG object to the Message Queue
4. system. Out. println (''activity ------> "+ thread. currentthread (). GETID ());
System. Out. println (''activityname ------>" + thread. currentthread (). getname ());
Handlerthread = new handlerthread ("handler_thread"); // generates a handlerthread object and implements the function of using logoff to process message queues. This class is used by Android applications.ProgramFramework provision
Handlerthread. Start (); // before using the getlooper () method of handlerthread, you must call start () of this class ()
Myhandler = new myhandler (handlerthread. getlooper ());
Message MSG = myhandler. obtainmessage (); // send MSG to the target object. The so-called target object is the handler object that generates the MSG object.