I am simultaneously downloading several images in separate threads. I need to set these images to adapter. I need to finish these threads in the order in which they were started, because I am using callbacks to inform adapter and…
How can I do this(finish threads in the order in which they were started)?
Finishing your threads in a particular order is counter to the idea of multi-threaded programming… you don’t want to start Thread 1, 2, and 3, and then dictate when they finish, because they may have tasks that take completely differing times to complete.
For example, if you are downloading two different things on two different threads, what if Thread 1 is downloading a 2 TB file and Thread 2 is downloading a 2 KB file? Obviously Thread 2 will complete long before Thread 1, and you don’t want your process to have to block waiting for Thread 1 to complete… I would suggest re-thinking what you are trying to accomplish and re-design accordingly to avoid this.