Consider this class AnimationThread:
class AnimationThread implements Runnable {
public void pause() {
doAnimation = false;
}
public void doStart(){
doAnimation = true;
}
@Override
public void run() {
if (doAnimation) {
}
try {
Thread.sleep(500);
}
catch (InterruptedException e) {
}
}
}
Now I start this thread in onCreateactivity (just showing the rough code):
AnimationThread animRunnable = new AnimationThread();
animationThread = new Thread(animRunnable);
animationThread.start();
But it run()is called only once (I traced the log to confirm this). I just want to know that when I started the topic, why is run()n’t it being called repeatedly with 500 sleep. It just gets called once.
source
share