-5
我有点困惑。我有包含可运行类的后台服务。在服务体中,我调用了使用我的可运行对象(在onCreate方法和onStartCommand中)创建新线程的方法。在启动新线程后,我调用了与网络一起工作的runnable类的一些方法,并且我在主线程中得到了Exception。主线程异常
我的问题是:如果我从我的服务调用独立线程的方法是在主服务线程上还是在第二个线程上执行?
public class myService extends Service {
public class myThread implements Runnable, LogListener, .... {
//networking methods herer
}
private void handleServiceStart{
if (!serviceStarted) {
Thread thread = new Thread(myThread);
thread.start();
}
thread.methodWithNetowrking();
...
}
public void onStart() {
this.handleServiceStart();
}
public int onStartCommand() {
this.handleServiceStart();
}