code: public void stop() {
      if (runnerThread == null) {
        return;
      }
  
      runnerThread.interrupt();
  
      nsLock.writeLock().lock();
      try {
        if (runnerThread == null) {
          return;
        }
  
        this.cancel();
        this.close();
  
        while (runnerThread.isAlive()) {
          runnerThread.interrupt();
          try {
            runnerThread.join(1000);
          } catch (final Exception e) {
            e.printStackTrace();
            return;
          }
        }
        runnerThread = null;
      } catch (Exception e) {
        e.printStackTrace();
      } finally {
        nsLock.writeLock().unlock();
      }
    }
docs: Stops the background stream thread.