android thread management onPause
Posted
by Kwan Cheng
on Stack Overflow
See other posts from Stack Overflow
or by Kwan Cheng
Published on 2010-06-16T16:19:36Z
Indexed on
2010/06/16
16:22 UTC
Read the original article
Hit count: 183
I have a class that extends the Thread class and has its run method implemented as so.
public void run(){
while(!terminate){
if(paused){
Thread.yield();
}else{
accummulator++;
}
}
}
This thread is spawned from the onCreate method.
When my UI is hidden (when the Home key is pressed) my onPause method will set the paused flag to true and yield the tread. However in the DDMS I still see the uTime of the thread accumulate and its state as "running".
So my question is. What is the proper way to stop the thread so that it does not use up CPU time?
© Stack Overflow or respective owner