Re: SocketChannels NIO
- From: Thomas Hawtin <usenet@xxxxxxxxxxxxxxxxx>
- Date: Mon, 23 Jan 2006 17:28:57 +0000
Stefan Schulz wrote:
I am not entirely sure about this, but i think you need to keep your channel in nonblocking mode as long as it is registered with a selector. However, if this really is your bottleneck, you can have one (or several) threads on standbye, which get handed a channel once it becomes readable, read as much data as possible, and then return to standbye mode.
One way of handling this is to copy from the channel into a PipedOutputStream (or saner equivalent) in your main selector handling thread. Then have worker thread work as traditional on the matching InputStream.
This can be particularly effective with tasks such as web serving. Connections will be idle most of the time. However bursts of activity occur where traditional I/O may be significantly simpler.
Tom Hawtin -- Unemployed English Java programmer http://jroller.com/page/tackline/ .
- References:
- SocketChannels NIO
- From: Andersen
- Re: SocketChannels NIO
- From: Stefan Schulz
- SocketChannels NIO
- Prev by Date: Re: Regular Expressions Question.
- Next by Date: Re: EJB newbie question
- Previous by thread: Re: SocketChannels NIO
- Next by thread: Re: SocketChannels NIO
- Index(es):
Relevant Pages
|