Hi,
In my configuration, several workers update a Sharedcount object by
increment or decrement the counter of the node.
I implemented this by this piece of code:
public void incrementForKey(String key) throws Exception {
SharedCount count = new SharedCount(this.framework,
this.path + "/" + key,0);
count.start();
count.setCount(count.getCount()+1);
}
However, I am worrying about the last line:
count.setCount(count.getCount()+1);
What happens, in case, two workers concurrently, try to increment or
decrement the node value? I suppose this is not atomic and so, how can I
solve that?
Benjamin.