Reputation: 2042
Is it possible to resume an interrupted Thread
in Android?
Upvotes: 3
Views: 2414
Reputation: 19837
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();
}
}
Upvotes: 3