Let's say I have a function that is dependent on a prior function running first such as:
populateList();
sortList();
is there a possibility in Android that these functions will run in parallel or out of sequence? In other words, can sortList run before populateList is completed?
CodePudding user response:
Short answer: yes.
Long answer: It depends. If what you have inside the methods is simple non-asynchronous code and if the function running this two methods is always called from a single thread or at least have some guards agains concurrent access; then yes. They will be always executed sequentially.
If, on the other hand, inside any of those methods there is some asynchronous code or new thread running, then it could happen that no. As well as if there is multiple threads trying to execute those two lines of your example.