Friday, February 14, 2014

Thread is stopped on the android system problems! ! !


First on a piece of code:
 
class A implements Runnable {

Thread thread;

public A () {
thread = new Thread (this);
thread.start ();
}

int i = 10;

public void run () {
while (true) {
/ / Do sth ..
i + +;
}
}
}

This is the case:
My new A in activity in the onCreate ();
After the thread is started, the phone is thrown into the side of care.
After some time, the system will stop off this thread.
A thread variable this time then there is a null or non-null it?

Or off the end of the main thread is the thread also followed the end of the sub-sub-thread variables were just freed up?
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
Release does not release what relationship? You are not allowed to do so inside the android.
Reply:
cited a floor snowrain_2008 reply:
release does not release what relationship? You are not allowed to do so inside the android.

Im such software, you need to keep tcp, music player, and so on. I want to clarify this, in the future to avoid this problem.
Reply:
Im such software, you need to keep tcp, time-consuming operation music player software is placed inside the service, not on the activity, the specific activity can be seen on the android recovery mechanism
Reply:
reference to the second floor xialonghua reply:
cited a floor snowrain_2008 reply: release does not release what? You are not allowed to do so inside the android.
Im such software, you need to keep tcp, music player, and so on. I want to clarify this, in the future to avoid this problem.



Downstairs did not see the references?
Reply:
references, 4th Floor snowrain_2008 reply:
reference to the second floor xialonghua reply: Quote floor snowrain_2008 reply: release does not release what? You are not allowed to do so inside the android.
Im such software, you need to keep tcp, music player, and so on. I want to clarify this, in the future to avoid this problem.


Downstairs did not see the references?


I say okay, service was open on a thread, the thread will be to kill off the situation does not kill off the service does not appear?
Even inside the onStart also perform service in the UI thread. Not to say that open service would solve the problem.
Please look at the problem will not be so one-sided, back to you when I simply can not see the downstairs someone replies. I did not say I would be so used, I just want to know.
Reply:
I ask the landlord to figure out yet, I have encountered the same problem, I want servic inside thread loop has been executed it, but aside over a period of time you will find the cycle stopped, ask for advice!
Reply:
According to my observation. In fact, the whole process thread stops being blown away, you can play in the application of oncreate log in, you will find will be killed after the system is started, the first call is the application oncreate, service also be killed and then boot up. But there is no trigger to start the thread is stopped. So what I have now put forward a single force in oncreate in initialization mode to ensure proper operation.
But do not know if my understanding is correct, this question has been
Reply:
reference to the 6th floor ylc88 reply:
ask the landlord to figure out yet, I have encountered the same problem, I want servic inside thread loop has been executed it, but aside over a period of time you will find the cycle stopped, ask for advice!

According to my observation. In fact, the whole process thread stops being blown away, you can play in the application of oncreate log in, you will find will be killed after the system is started, the first call is the application oncreate, service also be killed and then boot up. But there is no trigger to start the thread is stopped. So what I have now put forward a single force in oncreate in initialization mode to ensure proper operation.
But do not know if my understanding is correct, this question has been

No comments:

Post a Comment