docs: @SuppressWarnings("deprecation")
      public boolean cancel(boolean sync) {
  
          boolean success = false;
  
          try {
              switch (state) {
              case WAITING:
                  ParallelTaskManager.getInstance().removeTaskFromWaitQ(this);
                  this.state = ParallelTaskState.COMPLETED_WITHOUT_ERROR;
                  success = true;
                  break;
              case IN_PROGRESS:
                  if (executionManager != null
                          && !executionManager.isTerminated()) {
  
                      executionManager.tell(ExecutionManagerMsgType.CANCEL,
                              executionManager);
                      logger.info(
                              "Asked parallel task {} to stop from running...",
                              this.taskId);
  
                      if (sync) {
                          logger.info("Run cancel in SYNC mode... waiting for task to finish...");
                          while (!isCompleted()) {
                              try {
                                  Thread.sleep(100L);
                              } catch (InterruptedException e) {
                                  logger.error(" task {} interrupted ", this.taskId);
                              }
                          }
                          logger.info("Task completed! Cancellation is completed.");
                      } else {
                          logger.info("Run cancel in ASYNC mode... will now return...");
                      }
  
                  } else {
                      logger.info("manager already killed or not exist..");
                  }
                  this.state = ParallelTaskState.COMPLETED_WITH_ERROR;
                  success = true;
                  break;
              case COMPLETED_WITHOUT_ERROR:
              case COMPLETED_WITH_ERROR:
                  logger.info("task are already in completed state..no operation...");
                  success = true;
                  break;
              default:
                  break;
  
              }
  
          } catch (Exception e) {
              logger.error("cancel task {} error with exception details ",
                      this.getTaskId(), e);
          }
  
          return success;
      }