Saturday, February 8, 2014

Android in the service and compare the usefulness of the child thread?


            
service and child thread is without interface, you can not bind, you can also share data, can not replace the service with a sub-thread?
Reply:
High efficiency bar service, with sub-thread, Andrews If you start too many threads, then efficiency will be good. Memory consumption, but it is better to control the service is good control.
Reply:
service is actually running in the main thread, and if you need a lot of background and time-consuming data processing operations, the best way is to open a thread in the service of the child, rather than directly to open a sub-thread, so in order to improve the sub-thread priority, The system will not easily be killed.

The landlord said the service can not be used in place of the child thread? In fact, the function can be achieved, but still want to use the actual needs and scenarios, such as downloading data and other operations is best to open the sub-thread service, this sure beats directly open sub-thread.
Reply:
Usually no direct service to interact with the UI operation.
Such as timing of sending the request to the server, do the logging,
Or receive push messages back and so on.
Service can serve as an independent permanent background processes, threads must be attached to the process.
Service is also designed to improve the logical separation of application code written to improve scalability.
Service is most useful is the process of communication.

Reply:
Studied previously been directly open a sub-thread, the thread on the service after considering handle inside.

No comments:

Post a Comment