Android development, multiple threads share a handler

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.