The requirement is this: I need an object that can be accessed by different Activity, and then this object operates on multiple threads to perform multiple parallel operations. It feels that both single instance (custom class) plus thread and service plus thread can be used. But I just don’t know which one is more suitable. Please consult the advantages and disadvantages of the two.
First of all, you need to understand what a singleton is, a singleton, just to keep the global unique access … to put it bluntly, a static variable! ! !
My advice is.
The thread pool plus a single instance is OK … ..
If it is more time consuming, use intentservice, this is no problem .. (Many scans are written with this service)
If you want to update the UI, use handler… loop .. you also need to know this ..
The rest is written by yourself, I don’t know your business ~!