Creating the Array:
Uses the thread provided on startup since we only create the array once.
public static final Player[] PLAYERS = new Player[10];
Writing to Array:
Uses several different threads from a pool so that players can load concurrently.
public static Player loadPlayer(int freeIndex) {
//slow code that loads the player's saved data.
return PLAYERS[freeIndex] = player;
}
Reading from Array:
Uses a single thread to process players in order of their index.
public static void process() {
for(Player player : PLAYERS)
player.process();
}
Questions: Will players be immediately visible in method process after method loadPlayer is executed? If not (which I'm suspecting is the case) what approach should I take to fix the problem?