Thanks Ben. It was a copy and past mistake.  So that means method process()
must return as soon as possible.

On Tue, Jun 29, 2010 at 11:48, Benjamin Reed <br...@yahoo-inc.com> wrote:

watchers are executed sequentially and in order. there is one dispatch
thread that invokes the watch callbacks.

ben

ps - in 2) you do not install a watch.

On 06/29/2010 06:13 AM, André Oriani wrote:

Hi,

Are Watchers executed sequentially  or in parallel ? Suppose I want to
monitor the children of a znode for any modification.  I don't want the same
watcher to be re-executed while it is still executing.

1)

public class ChildrenWatcher implements Watcher{

     public void process(WatchedEvent event) {

          //get children and install watcher
          List<String>  children = zk.getChildren(path, this);

                   //process children

    }
}

2)

public class ChildrenWatcher implements Watcher{

     public void process(WatchedEvent event) {

          //get children
          List<String>  children = zk.getChildren(path, null);

                   //process children

         //install watcher
         zk.getChildren(path, null)
    }
}

Does both code achieve the goal or just the code number 2 ?

Tks,
André

Reply via email to