如果我有这样的课程:
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
?