ChannelFuture.await() and ChannelFutureListener.operationComplete()

Trustin Lee tlee at redhat.com
Wed Apr 8 05:38:22 EDT 2009


ChannelFuture Javadoc has been improved to address this FAQ.  Check the trunk.

— Trustin Lee, http://gleamynode.net/

On Sat, Apr 4, 2009 at 2:18 PM, Utkarsh Srivastava <utkarsh at gmail.com> wrote:
> 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's IO threads).
>
> In Approach 2, the thread that calls the write blocks until the write
> finishes.
>
> Utkarsh
>
> On Fri, Apr 3, 2009 at 8:55 PM, hezjing <hezjing at gmail.com> wrote:
>>
>> Hi
>> I'm following the Writing a Time Server chapter of Netty 3.1 user's guide.
>> Here is the code snippet to close the connection after a message is
>> written successfully:
>> ChannelFuture f = ch.write(time);
>> f.addListener(new ChannelFutureListener() {
>> public void operationComplete(ChannelFuture future) {
>> Channel ch = future.getChannel();
>> ch.close();
>> }
>> });
>>
>> I think the above code can also be simplified to the following (?):
>> ChannelFuture f = ch.write(time);
>> f.await();
>> ch.close();
>>
>> Am I correct to say that both approaches are identical?
>>
>> --
>>
>> Hez
>>
>> _______________________________________________
>> netty-users mailing list
>> netty-users at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/netty-users
>>
>
>
> _______________________________________________
> netty-users mailing list
> netty-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/netty-users
>
>




More information about the netty-users mailing list