当线程被中断时,Android应用程序崩溃

时间:2018-04-21 14:30:19

标签: android multithreading android-studio android-thread

我有一个线程在我的应用程序中运行但是当它完成它的工作并且我尝试停止它时线程崩溃应用程序并重新启动导致崩溃循环直到我重新打开应用程序 Runnable:

final class TheThread implements Runnable{
    public void run(){
        if (!thread.isInterrupted()){
        //dowork
        thread.interrupt();
        }
    }
}

线程创建:(变量线程在oncreate中作为常规Thread对象进行了内置)

    thread = new Thread(new TheThread());
    thread.setPriority(START_STICKY);
    thread.start();

1 个答案:

答案 0 :(得分:0)

找到我需要调用的Problom Looper.Preper();