You do not want to do this. Each request is launched in its own thread. If the code that is executed in the browser action changes the list, then two requests can simultaneously change the list and corrupt the data. This is why it is not recommended to access static resources from a non-static context, and probably why your tool is warning you.
Look at this
http://download.oracle.com/javase/6/docs/api/index.html?java/util/concurrent/package-summary.html
in particular, the part on how an ArrayList is not synchronized. Also note that in paragraph I mention the solution, in particular
List list = Collections.synchronizedList(new ArrayList(...));
This is one way to do this. But this is still not a good idea, namely because it can be slow. If this is not a commercial application, and you are not dealing with a large volume, you can probably get it without making it better. If this is a type of application that only hits a few times a day, you can ignore this warning, realizing that it is possible that something bad will happen if the two requests go to each other.
Best solution: since you have a database, I just get information from db as needed, i.e. as requests arrive. You can use some caching technologies for performance.
The reason I don't like the idea of ββthe Singleton Pattern is that even if this makes the warning go away, it does not in itself affect the underlying synchronization problem. However, there are thread-safe http://en.wikipedia.org/wiki/Singleton_pattern#Traditional_simple_way_using_synchronization that may work in this case.
source share