In the process of doing the project, suddenly found that the project started a number of threads, but only one handler, instead of requiring each thread to open a separate handler, note:
Handler =NewHandler () {@Override Public voidhandlemessage (Message msg) {String Rs_result=NULL;//result parsing in JSONString rs_msg=NULL;//JSON-parsed msgString _rs = msg.obj.toString ();//JSON string ... Switch(msg.what) { Case1:... Receive the first boot thread Case2:... Receive the second boot thread} }};
How to start a thread:
New Uploadhttpthread (handler,params,ffile,1); New Thread (Uploadthread). Start ();
But there is a doubt that I started multiple threads in an activity, but I don't know if the thread continues to execute after handler receives the message? Do I need to close it manually? How do I close the thread??
Android development, multiple threads share a handler