I have an object which is a singleton. This object declares:
List players = new ArrayList();
The same object al
If you don't plan on updating it often use a CopyOnWriteArrayList otherwise @tieTYT's suggestion works.
You can also manage this yourself by returning a copy of the list instead of the actual list within the getPlayers. (If you are using Collections.synchronizedList)
public List getPlayers(){
synchronized(list){
Collections.unmodifiableList(new ArrayList(list));
}
}
This has the side effect of a list being out of date after an add/remove is done
Edit: Stealing Grzegorz suggestion for unmodifiableList