title: Query regarding writing to channel via netty through multiple threads
body: <p>Consider this method from one of my handlers at server side</p>
  
  <pre><code>@Override
  public void channelRead(final ChannelHandlerContext ctx, Object msg) throws Exception {
  
      try {
          io.netty.channel.ChannelFuture f = ctx.writeAndFlush("Executing command now...");
          System.out.println("command execution future - " + f);
  
          new Thread(new Runnable() {
              int i = 4;
              @Override
              public void run() {
                  while(i &gt;= 0 ) {
                      io.netty.channel.ChannelFuture f = ctx.writeAndFlush("beat till command");
                      System.out.println("beat till command future - " + f);
                      try {
                          Thread.sleep(6*1000);
                          i--;
                      } catch (InterruptedException e) {
                          e.printStackTrace();
                      }
  
                  }
  
              }
          }).start();
  
          //assume some processing here
          Thread.sleep(20 * 1000);
  
      } catch (Exception e) {
          e.printStackTrace();
      }
      ctx.fireChannelRead(msg);
  }
  </code></pre>
  
  <p><br>
  In above code when I write to channel in same thread it is immediately sent to the client, i.e. this message <code>ctx.writeAndFlush("Executing command now...")</code> is sent immediately
  <br><br>
  But when I try the same thing from a different thread, it is not sent immediately( <code>ctx.writeAndFlush("beat till command")</code> ). Also the future <code>DefaultChannelPromise@5aa824c(incomplete)</code> shows that the operation is incomplete. All these calls are deferred I guess and are completed once the main thread is done. Why is that so? Some locks on ctx?
  <br>
  Please tell me what am I doing wrong here?  </p>