当前位置: 动力学知识库 > 问答 > 编程问答 >

java - Why calling a new thread will not work in AsyncTask's doInbackground()?

问题描述:

While this will work:

new Thread(new Classimplementingrunnable(stuff, dostuff()).start();

This will not:

new Thread(){

public void run(){

Log.i("tag", "I am inside thread");

dostuff();

}

};

No error occurs, it will just ignore it and it wont start a seperate thread, so "I am inside thread" will not show.

网友答案:

You need to call the start() method on your Thread inorder to make it run.

new Thread(){
    @Override
    public void run(){
        Log.i("tag", "I am inside thread");
        dostuff();
    }
}.start();
分享给朋友:
您可能感兴趣的文章:
随机阅读: