code: private static void waitForChannelClosure(Channel channel, long timoutInMs) {
          final long start = System.currentTimeMillis();
          final long until = start + timoutInMs;
          try {
              while (!channel.isClosed() && System.currentTimeMillis() < until) {
                  Thread.sleep(CLOSURE_WAIT_INTERVAL);
              }
              logger.trace("Time waited for channel closure: " + (System.currentTimeMillis() - start));
          } catch (InterruptedException e) {
              logger.trace("Interrupted", e);
          }
          if (!channel.isClosed()) {
              logger.trace("Channel not closed in timely manner!");
          }
      }
docs: Blocks until the given channel is close or the timout is reached
  
  @param channel the channel to wait for
  @param timoutInMs the timeout