Reputation: 26538
Please can anyone provide me explanation in corresponding to method call stack
Hello there I am developing an android app in which I haver to upload some mp3 files on server
This is the the function given me to me for uploading the files
uploadToServer(String arg1, String arg2)
Now I have to send multiple upload request. I have two ArrayList of arg1 and arg2
So I am using an for loop for iterating ArrayList and sending uploading request.
So Now the problem is before first upload gets completed second starts automatically. I havent implemented threads. So why it is happening . According to call stacks concept until the first request gets over Second can.t be started. How come the second iteration of for loops gets started until the first gets finished.
Upvotes: 0
Views: 291
Reputation: 4296
Just for completeness:
An asynchronous method will return before the action it starts completes. This is perfectly fine the method has done what it should have: start a background task that performs the action.
So in short, an asynchronous method is just an initiator for a separate (anonymous) thread that handles the action. When completed, it either fires off an event, or call a callback method (depending on the used programming language).
Upvotes: 1