Fast question about threading inside Netty
"Trustin Lee (이희승)"
trustin at gmail.com
Wed Mar 24 01:53:45 EDT 2010
Crystal clear explanation. Thanks a lot!
Trustin
Marzullo wrote:
> You know, I wrote such question after I've read about boss thread and worker
> thread in case of NIO socket and OIO socket, if you look up the doc, it
> gives the idea. The point is:
>
> OIO socket:
> Boss thread accepts for connections, when connection is accepted (3 way
> handshake completed in case of TCP), it creates a channel which represents
> the accepted connection itself. This channel is handed to a worker thread
> (often referred as I/O thread) got from thread pool. On such threads, I/O
> operations are blocking. If you ever implemented a server in C, this is very
> similar, if not equal to, 1-accepting a socket then 2-create a thread and
> 3-hand socket descriptor to such thread which will block on reads and
> writes, that's it.
> So here the important difference is that you have one accepted channel per
> I/O thread and every I/O operation within such thread is blocking.
>
> NIO socket:
> Similar to above, boss thread accepts connection, create channel for such
> connection and hands it to worker thread. The difference is here, you can
> have more than one channel handed to worker thread, then of course I/O must
> be non blocking otherwise by blocking on one channel you'd starve the
> others...
> So here is the point when I read on the docs:
>
> "If await() is called by an event handler method, which is called by the
> I/O thread, the I/O operation it is waiting for might never be complete
> because await() can block the I/O operation it is waiting for, which is a
> dead lock. "
>
> so if you wait withing such worker thread (I/O thread) you might
> starve/lower responsiveness on other channels or even cause deadlock
> depending on what you actually do.
>
> It'd be nice to have clarifications from T. Lee about all this.
> Thanks.
>
--
what we call human nature in actuality is human habit
http://gleamynode.net/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 260 bytes
Desc: OpenPGP digital signature
Url : http://lists.jboss.org/pipermail/netty-users/attachments/20100324/3171b58e/attachment-0001.bin
More information about the netty-users
mailing list