Я пытаюсь запустить 7 асин c сопрограмм одновременно, но только 4 асин c сопрограммы, кажется, работает
btn.setOnClickListener(View.OnClickListener {
var urls = arrayOf(mUrl,mUrl2,mUrl3,mUrl4,mUrl5,mUrl5,mUrl5)
GlobalScope.launch(Dispatchers.Default) {
for(url in urls){
async { getlocationSourcecode(url) } // This is jsoup parsing html method
}
Log.i("MainActivity", " TEST : This Main coroutine is running in ${Thread.currentThread().name} thread ")
}
})
Это мой журнал, где Вы можете видеть, что работают только 4 потока
2020-05-02 16:52:15.177 11578-11578/com.example.android.iscrape I/MainActivity: TEST : This Main thread is running in main thread
2020-05-02 16:52:20.759 11578-11674/com.example.android.iscrape I/MainActivity: TEST : This asyncTask thread is running in DefaultDispatcher-worker-2 thread
2020-05-02 16:52:20.762 11578-11676/com.example.android.iscrape I/MainActivity: TEST : This asyncTask thread is running in DefaultDispatcher-worker-4 thread
2020-05-02 16:52:20.763 11578-11675/com.example.android.iscrape I/MainActivity: TEST : This asyncTask thread is running in DefaultDispatcher-worker-3 thread
2020-05-02 16:52:20.765 11578-11673/com.example.android.iscrape I/MainActivity: TEST : This asyncTask thread is running in DefaultDispatcher-worker-1 thread
2020-05-02 16:52:22.977 11578-11674/com.example.android.iscrape I/MainActivity: TEST : This asyncTask thread is running in DefaultDispatcher-worker-2 thread
2020-05-02 16:52:23.761 11578-11674/com.example.android.iscrape I/MainActivity: TEST : This asyncTask thread is running in DefaultDispatcher-worker-2 thread
2020-05-02 16:52:24.393 11578-11674/com.example.android.iscrape I/MainActivity: TEST : This asyncTask thread is running in DefaultDispatcher-worker-2 thread
2020-05-02 16:53:43.252 11578-11675/com.example.android.iscrape I/MainActivity: TEST : This asyncTask thread is running in DefaultDispatcher-worker-3 thread
2020-05-02 16:55:22.039 11578-11673/com.example.android.iscrape I/MainActivity: TEST : This asyncTask thread is running in DefaultDispatcher-worker-1 thread
2020-05-02 16:55:22.453 11578-11673/com.example.android.iscrape I/MainActivity: TEST : This asyncTask thread is running in DefaultDispatcher-worker-1 thread
2020-05-02 16:55:22.923 11578-11673/com.example.android.iscrape I/MainActivity: TEST : This asyncTask thread is running in DefaultDispatcher-worker-1 thread
2020-05-02 16:55:23.397 11578-11675/com.example.android.iscrape I/MainActivity: TEST : This asyncTask thread is running in DefaultDispatcher-worker-3 thread
2020-05-02 16:55:23.863 11578-11675/com.example.android.iscrape I/MainActivity: TEST : This Main coroutine is running in DefaultDispatcher-worker-3 thread
Это начальная часть метода jsoup с также разборами json Здесь я зарегистрировал имя потока, чтобы проверить, сколько потоков запущено
suspend fun getlocationSourcecode(url: String) {
lateinit var trying: String
Log.i("MainActivity", "TEST : getDatax called ")
Log.i("MainActivity", " TEST : This asyncTask thread is running in ${Thread.currentThread().name} thread ")