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