If I have a class like this:
public class Example
{
ArrayList<String> vector;
public Example singleton = new Example();
private Example()
{
//Read data from BD and fill the vector. Example vector: ["foo","voo","faa","vuu","vee"]
}
public synchronized removeElement()
{
vector.remove(0);
}
public synchronized changeElement()
{
vector.set(0,"fii");
}
}
If there are multiple instances running and one of them executes the method removeElement, what happens with the values of the other instance? And if one of them executes the method changeElement?
GAE can have multiple JVM instances running in parallel, so updating value in memory will only be visible on that instance.
You should use shared data storage: either memcache (free, fast, but volatile) or datastore (costly, slower, but consistent).