class server {
private Vector<Msg> v = new ...
...
public void deliver(Msg msg) {
...
v.add(msg);
}
}
class client {
private server s = server.getInstance(); // singleton
...
public void propose() {
s.deliver(new Msg( ... ));
}
}
如果多个并发客户端通过Msg
[非同步!]deliver
方法将值(对象)传递给服务器,是否可以假设任何客户端调用 [或者更准确地说,首先进入]deliver
将其值首先存储在v
-还是deliver
强制同步以使这个假设成立?