我想用IntentService做兩個saperate後臺任務。所以,只是我想知道這兩個intent服務會生成兩個saperate工作線程或第二個將等待第一個完成。兩個intent服務會生成兩個不同的worker線程嗎?
Ex。從活動
public class IntentServiceOne extends IntentService {
public IntentServiceOne() {
super("IntentServiceOne");
}
@Override
protected void onHandleIntent(@Nullable Intent intent) {
// code to execute
}
}
public class IntentServiceSecond extends IntentService {
public IntentServiceSecond() {
super("IntentServiceSecond");
}
@Override
protected void onHandleIntent(@Nullable Intent intent) {
// code to execute
}
}
代碼:
Intent intentOne=new Intent(this, IntentServiceOne.class);
startService(intentOne);
Intent intentSecond=new Intent(this, IntentServiceSecond.class);
startService(intentSecond);