Is it possible to resume an interrupted Thread in Android?
You shouldn't resume Thread by its API, resume() method is depracated (reason).
You can simulate resuming Thread by killing it and starting a new one:
/**
Since Thread can't be paused we have to simulate pausing.
We will create and start a new thread instead.
*/
public class ThreadManager
{
private static GameThread gameThread = new GameThread();
public static void setRunning(boolean isRunning)
{
if (isRunning)
{
gameThread = new GameThread();
gameThread.setRunning(true);
gameThread.start();
}
else
{
gameThread.setRunning(false);
}
}
public static boolean isRunning()
{
return gameThread.isRunning();
}
public static void join() throws InterruptedException
{
gameThread.join();
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With