Tuesday, February 11, 2014
android relationship of components and thread! ! !
I know there is an android a main thread, activity on the interfaces belonging to the main thread. If I then later by the method creates a new activity or service and the like, these components are part of the newly created main thread it? Or that each new component will belong after creating a new sub-thread? ? ? So in order not to do complex background activity calculated to create service? Why not new thread it?
Reply:
You said a little dizzy ...
Recommend a look at what is the UI thread, android is how the UI thread.
Reply:
1, every time you create a component, this component is executed in the UI thread, instead of creating a new thread
2, as to why not to do complex background activity calculated to avoid ANR, in fact, even if done in the service, and also the UI thread, although I have not done the experiment, I think if you run more still appear ANR,
3, why not new thread it? Because android UI operation is only allowed to do in the UI thread, the thread in order to avoid the risk. Or are they never thought android allows developers to manipulate the UI in the other thread, because the multi-thread synchronization will affect the efficiency
Reply:
My understanding is that the service is not a common activity in the process. This creates a service to calculate, you can save more time for the activity. Opposite the thread, which is part of the process of the activity is in the child, it will take up where the process of resource activity, and thus affect the time.
Reply:
Android the main thread looper to hide, the main thread should be responsible for the distribution of local news in application, components are running in the main thread.
However, some components may function in other threads running: If aidl of functions. These are implemented system secretly. It's complicated.
Reply:
The landlord said the process it
Components are unreasonable ah this argument thread
Reply:
1 You have to be clear: service specified if there is no separate thread, then the main activity is in the same thread, that is the main thread, then not be able to do time-consuming operation in this service, otherwise will abort.
2 If you do not have a Thread calls start () method, and it is the main activity in a thread, nor do time-consuming operation, you can do the next test
Proposed landlord or the principle of the thing to look at.
Reply:
Consult the way upstairs, I do know that activity inside the time-consuming operation, if there are some design to the activity of the more time-consuming UI update operation is not to open a new thread to complete? But after all, the newly opened thread is not the main thread can not operate UI, this time is not needed to complete the UI handler updates ah?
Reply:
Reply on: 2012-05-02 17:01:29
Reply:
Android What are the components of the test run in the main thread?
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment