如何停止线程

时间:2016-08-30 10:18:45

标签: java android

如果记录被提取,我想停止我的帖子请帮助我。这是我的代码。

 if (dialog==null) {
        dialog = ProgressDialog.show(AgentProgress.this, "",
                "Fetching Records...", true);
        new Thread(new Runnable() {
            public void run() {


                try {
                    Thread.sleep(5000);
                    loadnames load1 = new loadnames();
                    load1.execute("");

                } catch (InterruptedException e) {
                    Thread.currentThread().interrupt(); //this is a MUST
                }
            }


        }).start();


    }

在此加载名中,如果获取名称则获取名称,然后线程将停止。

0 个答案:

没有答案
相关问题