how thread execute inside for-loop

214 views Asked by At

If we have below code, is for-loop will wait until runner complete its work then go from i=0 to i=1 or not ? how this code will execute?

for (int i=0; i<5; i++) { 
                Runnable runner = new RevokGrantTask(token, threadAttachments, currentUserID, userId, true); 
                log.info("Adding: " + thread); 
                executor.execute(runner); 
            }
1

There are 1 answers

0
Ankur Srivastava On BEST ANSWER

you are submitting 5 tasks here through the loop.its not like , finish one task and then go to next .5 tasks will be submitted and order of results could not be necessarily not in order.