Reputation: 3
I have issues as follows:
Upvotes: 0
Views: 1636
Reputation: 3201
I've never down multithreading in andriod land but from what you described you need to have a loop with associated blocking mechanisms. Look at this sight to get an overview of multithreading.
Upvotes: 0
Reputation: 22066
i think you need a countdownTimer, which working as loop
public void looper(final MediaPlayer secAudio) {
try
{
tns_DCounter = new CountDownTimer(2000, 1000) {
public void onTick(long millisUntilFinished) {
try
{
mPlayer.start();
}catch (Exception e) {
}
}
public void onFinish() {
try
{
secAudio.start();
tns_DCounter2 = new CountDownTimer(3000, 1000) {
public void onTick(long millisUntilFinished) {
}
@Override
public void onFinish() {
looper(secAudio);
}
};
tns_DCounter2.start();
}catch (Exception e) {
// TODO: handle exception
}
}
};
tns_DCounter.start();
}catch (Exception e) {
}
}
Upvotes: 1
Reputation: 1500035
You can't restart a thread. The closest you can come is to make the thread pause somehow (e.g. wait on a monitor) and then resume it later (e.g. by notifying that monitor). But once a thread has actually stopped, it can't be restarted.
Upvotes: 1