#vulnerable code 
                              @Override
  public void run()
  {
    while (running)
    {
      if (this.kcp.isClosed())
      {
        this.running = false;
        continue;
      }
      long st = System.currentTimeMillis();
      this.kcp.update();
      if (this.kcp.needUpdate())
      {
        continue;
      }
      long end = System.currentTimeMillis();
      while ((end - st) < this.interval)
      {
        synchronized (waitLock)
        {
          try
          {
            waitLock.wait(this.interval - end + st);
          } catch (Exception ex)
          {
          }
        }
        break;
      }
    }
    nioEventLoopGroup.shutdownGracefully();
    this.channel.close();
  } 
                            #location 18 
                            #vulnerability type THREAD_SAFETY_VIOLATION
#fixed code
                              @Override
  public void run()
  {
    while (running)
    {
      if (this.kcp.isClosed())
      {
        this.running = false;
        continue;
      }
      this.kcp.update();
      if (this.kcp.needUpdate())
      {
        continue;
      }
      synchronized (waitLock)
      {
        try
        {
          waitLock.wait(this.interval);
        } catch (Exception ex)
        {
          System.out.println("error..........");
        }
      }
    }
    nioEventLoopGroup.shutdownGracefully();
    this.channel.close();
  }