Android service differs from thread

Source: Internet
Author: User

1. Theservice is a mechanism for Android, and when it runs, if it is a local service, then the corresponding service is running on the main thread of the master process. In the case of remote service, the corresponding service is running on the main thread of the standalone process , andthe communication between the service and the caller is synchronous (either remote service or local service). It has nothing to do with threading!

2.thread operation is independent of activity, that is, when an activity is finished, if you do not actively stop the thread or thread in the Run method is not completed, thread will also be executed. So there's a problem here: When the Activity is finished, you no longer have a reference to the thread, which is the next time you start, you can't control the thread you created, and the service can. On the other hand, you have no way to control the same Thread in different Activity.

3. You can register Broadcastreceiver in the Service and control it elsewhere by sending broadcast, which the Thread cannot do.

Android service differs from thread

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.