/**
   * Executes example.
   *
   * @param args Command line arguments, none required.
   * @throws GridException If example execution failed.
   */
  public static void main(String[] args) throws GridException {
    try (Grid g = GridGain.start("examples/config/example-compute.xml")) {
      System.out.println();
      System.out.println("Compute schedule example started.");

      // Schedule output message every minute.
      GridSchedulerFuture<?> fut =
          g.scheduler()
              .scheduleLocal(
                  new Callable<Integer>() {
                    private int invocations;

                    @Override
                    public Integer call() {
                      invocations++;

                      try {
                        g.compute()
                            .broadcast(
                                new GridRunnable() {
                                  @Override
                                  public void run() {
                                    System.out.println();
                                    System.out.println("Howdy! :) ");
                                  }
                                })
                            .get();
                      } catch (GridException e) {
                        throw new GridRuntimeException(e);
                      }

                      return invocations;
                    }
                  },
                  "{5, 3} * * * * *" // Cron expression.
                  );

      while (!fut.isDone()) System.out.println(">>> Invocation #: " + fut.get());

      System.out.println();
      System.out.println(">>> Schedule future is done and has been unscheduled.");
      System.out.println(">>> Check all nodes for hello message output.");
    }
  }