code: private void cancelScan() {
          if (rescanIncompleteTask != null) {
              rescanIncompleteTask.cancel(true);
              rescanIncompleteTask = null;
          }
          if (rescanUndeployTask != null) {
              rescanUndeployTask.cancel(true);
              rescanUndeployTask = null;
          }
          if (scanTask != null) {
              scanTask.cancel(true);
              scanTask = null;
          }
      }
docs: Invoke with the object monitor held