【发布时间】:2016-09-22 12:37:42
【问题描述】:
如果我有这样的课程:
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");
}
}
如果有多个实例在运行,其中一个执行removeElement方法,那么另一个实例的值会发生什么?如果其中一个执行changeElement方法?
【问题讨论】:
标签: google-app-engine synchronization instance