Reputation: 827
I have two asynctask which parse website using Jsoup and a retrofit instance which retrive the Json data using website API . Does all this three task continue in parallel or are executed sequentially ? Also i can only set my recycler adapter when all three task is completed ( 2 asynctask and 1 Retrofit).
How do i know when all the three task is completed (in case if they are executed in parallel) so i can set the adapter of recyclerview ?
Upvotes: 0
Views: 421
Reputation: 3026
If you are using AsyncTask.execute() then your two Jsoup tasks will be executed one by one in a background thread.
Your retrofit call will start as soon as a thread from retrofit threadpool is free.
Hence these tasks will start in parallel.
To keep a track that all the tasks are complete you can create a common callback method which is being called on success of these tasks. OnPostExecute of Asynctask call this callback and then onSuccess of Retrofit API call call this callback.
Increase a count variable when u receive the callback.. when count reaches 3.. set the adapter.
Please note : you will have to consider error handling scenarios.
Upvotes: 1