-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();
}