I defined a Runnable which starts after a button clicked, it changes image of a ImageView every 1 second. There is an other button in my view that when user click on that, again I start that Runnable but this time it changes image of ImageView every 2 seconds and so on.
My question is: when I click on second button, now do I have to individual thread running or it just stop first instance of Runnable and start the other instance?
Note: I read some topics about threads and Runnable in android but still the different is not clear for me. Also reading this question and it's answers head me hear to ask my own question. Java - Running a thread twice
Sorry for bad English.
Runnable part of my code:
private final Runnable mRunnable = new Runnable() {
public void run() {
if (mIsFlashOn) {
if (mSwap) {
mImageViewBeam.setVisibility(View.VISIBLE);
mSwap = false;
mHander.postDelayed(mRunnable, 10000 / ((mStrobeCounter * 5) + 10));
} else {
mImageViewBeam.setVisibility(View.GONE);
mSwap = true;
mHander.postDelayed(mRunnable, 10000 / ((mStrobeCounter * 5) + 10));
}
}
}
};