In Approach 1, the thread that calls the write does not block and can go on to do the other stuff. The channel is closed by the thread that eventually finishes the write (one of Netty&#39;s IO threads).<br><br>In Approach 2, the thread that calls the write blocks until the write finishes.<br>
<br>Utkarsh<br><br><div class="gmail_quote">On Fri, Apr 3, 2009 at 8:55 PM, hezjing <span dir="ltr">&lt;<a href="mailto:hezjing@gmail.com">hezjing@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi<div><br></div><div>I&#39;m following the <a href="http://www.jboss.org/file-access/default/members/netty/freezone/guide/3.1/html_single/index.html#d0e489" target="_blank">Writing a Time Server</a> chapter of Netty 3.1 user&#39;s guide.</div>

<div><br></div><div>Here is the code snippet to close the connection after a message is written successfully:</div><div><br></div><div><div><div>ChannelFuture f = ch.write(time);</div><div>f.addListener(new ChannelFutureListener() {</div>

<div><span style="white-space: pre;">        </span>public void operationComplete(ChannelFuture future) {</div><div><span style="white-space: pre;">                </span>Channel ch = future.getChannel();</div>
<div><span style="white-space: pre;">                </span>ch.close();</div><div><span style="white-space: pre;">        </span>}</div><div>});</div><div><br></div><div><br></div><div>I think the above code can also be simplified to the following (?):</div>

</div><div><br></div><div>ChannelFuture f = ch.write(time);</div><div>f.await();</div><div>ch.close();</div><div><br></div><div><br></div><div>Am I correct to say that both approaches are identical?</div><div><br></div></div>
<font color="#888888">
<div><br></div><div>-- <br><br>Hez<br>
</div>
</font><br>_______________________________________________<br>
netty-users mailing list<br>
<a href="mailto:netty-users@lists.jboss.org">netty-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/netty-users" target="_blank">https://lists.jboss.org/mailman/listinfo/netty-users</a><br>
<br></blockquote></div><br>