Lets say that my program is currently in a for loop, but for some reason its taking too long. Lets say that somehow the algorithm is so slow that it takes about 500ms to loop through maybe 100 elements in the array.
Is it possible that while the program is inside the array, perhaps doing work with element number 50, that I get incoming commands from the network, telling me to add more elements or delete elements from the array?
A practical example is a matchmaking queue server. Every time a user joins, the server will try to match players as best as it can by calling a function, but it may be possible that a player who is in the queue, who hasn't been "reached" yet by the function, to simply leave and exit. Would this somehow corrupt the for loop search?
Summary: I have an array I want to loop through, can it have its elements changed (add/delete) during the for loop caused by external functions? Or will those functions be called after the program is done with the for loop? (Like a database being locked while a query is being worked into it to prevent these same problems)