- // Safety check
- int vr = variableMap.get(name);
- if(vr == 0) return false;
- if(!subscriptionSet.add(name)) return false;
- subscribedNames.add(name);
- System.err.println("subscribed : " + name + " => " + subscribedNames.size());
- subscription.add(vr);
- subscribe(new int[] { vr });
- return true;
+ synchronized(syncObject) {
+ // Safety check
+ int vr = variableMap.get(name);
+ if(vr == 0) return false;
+ if(!subscriptionSet.add(name)) return false;
+ subscribedNames.add(name);
+ subscription.add(vr);
+ subscribe(new int[] { vr });
+ return true;
+ }