JobIntentServices是否限制线程数?具有多个JobIntentServices的应用程序仅为所有服务提供两个线程

问题描述

我期望多个JobIntentServices始终使用一个线程。

我有几个JobIntentServices

class Client1 : JobIntentService() {
...
}

class Client2 : JobIntentService() {
...
}

class Client3 : JobIntentService() {
...
}

class Client4 : JobIntentService() {
...
}

,依此类推。每个前任都有一个意图:

val client1Intent = Intent(this,Client1::class.java)

client1Intent.putExtra("some_name",info) 
client1Intent.putExtra("other_name",otherInfo) Client1.enqueueWork(this,client1Intent)

当我在override fun onHandleWork(intent: Intent)上查看线程

override fun onHandleWork(intent: Intent) {
...
Log.d(TAG,"Current THREAD: ${Thread.currentThread()}")
}

我在logcat中看到,服务仅分成两个线程:

线程[AsyncTask#2,5,main] 线程[AsyncTask#1,5,main]

因此,它们每次仅运行两次。我期望asynctasks的数量等于JobIntentServices的数量。为什么不是这样?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)