Hi Mark,

On 3/13/07, Mark Webb <[EMAIL PROTECTED]> wrote:
I was looking at the 2 HTTP examples in Mina1.1, and have always wondered
this:  Why, if at line 50 of
org.apache.mina.example.httpserver.stream.HttpProtocolHandler a comment says
"You *MUST* execute stream I/O logic in a separate thread." there is a
stream based HTTP server example?  Is this just for illustrative purposes
and not intended for production level systems?  Or does this comment not
hold true anymore?

As you know, InputStream.read() is a blocking operation.  If you block
the current I/O processor thread (or the thread pool thread) by
calling read(), it's simply a dead lock because the I/O processor (or
the event dispatcher) can't perform any I/O operation when you wait
for data.  That's why you need to spawn a new thread or use a
different thread pool.

Moreover, I always recommend you not to use the StreamIoHandler.  Only
use it if you have inevitable backward compatibility issues.

HTH,
Trustin
--
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP Key ID: 0x0255ECA6

Reply via email to