@Override
    public void processResult(int rc, String path, Object ctx, List<String> children) {
      switch (KeeperException.Code.get(rc)) {
        case CONNECTIONLOSS: {
          // Connection to the server has been lost, getting tasks again.
          try {
            recreateZKConnection();
          } catch (Exception e) {
            break;
          }
          getTasks();
          break;
        }

        case OK: {
          if (children != null) {
            try {

              LOG.info("Executing each task as a separate thread");
              List<Thread> tasksList = new ArrayList<>();
              for (String task : children) {
                String threadName = agentName + "_" + task;
                Thread t = new Thread(() -> {

                  LOG.info("Executing task : " + task + " of agent : " + agentName);
                  zk.getData(
                    ChaosConstants.CHAOS_AGENT_STATUS_PERSISTENT_ZNODE
                      + ChaosConstants.ZNODE_PATH_SEPARATOR + agentName
                      + ChaosConstants.ZNODE_PATH_SEPARATOR + task,
                    false, getTaskForExecutionCallback, task);

                });
                t.setName(threadName);
                t.start();
                tasksList.add(t);

                for (Thread thread : tasksList) {
                  thread.join();
                }
              }
            } catch (InterruptedException e) {
              LOG.error(
                "Error scheduling next task : " + " for agent : " + agentName + " Error : " + e);
            }
          }
          break;
        }

        default:
          LOG.error("Error occurred while getting task",
            KeeperException.create(KeeperException.Code.get(rc), path));
      }
    }
Callback used while getting Tasks for agent if call executed without Exception, It creates a
separate thread for each children to execute given Tasks parallely.
hbase-it/src/main/java/org/apache/hadoop/hbase/chaos/ChaosAgent.java