【发布时间】:2017-10-13 13:19:05
【问题描述】:
我想使用IntentService 执行两个单独的后台任务,并且我想知道两个意图服务是否会生成两个单独的工作线程,或者第二个将等待第一个完成。
例如
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);
【问题讨论】:
标签: java android multithreading android-intentservice