You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@avro.apache.org by Yang <te...@gmail.com> on 2011/06/16 01:29:35 UTC

NettyServer multi-thread?

I guess the answer is almost surely that Netty would start multiple threads
to read the socket channel, just trying to confirm..

when we create a NettyServer, we pass in a Single Responder. if Netty
underneath creates many threads , the same responder (and netty handler)
will be shared between these threads, so that I have to be careful in the
Responder/avro handler implementation, so that it's thread-safe, right?

thanks
Yang

Re: NettyServer multi-thread?

Posted by Yang <te...@gmail.com>.
Thanks James

On Wed, Jun 15, 2011 at 8:13 PM, James Baldassari <jb...@gmail.com>wrote:

> Hi Yang,
>
> That's correct.  The NettyServer constructor uses
> Executors.newCachedThreadPool() to create a thread pool for servicing
> incoming requests.  The Responder can be invoked by multiple threads from
> this thread pool, so the Responder should be thread-safe.
>
> -James
>
>
>
> On Wed, Jun 15, 2011 at 7:29 PM, Yang <te...@gmail.com> wrote:
>
>> I guess the answer is almost surely that Netty would start multiple
>> threads to read the socket channel, just trying to confirm..
>>
>> when we create a NettyServer, we pass in a Single Responder. if Netty
>> underneath creates many threads , the same responder (and netty handler)
>> will be shared between these threads, so that I have to be careful in the
>> Responder/avro handler implementation, so that it's thread-safe, right?
>>
>> thanks
>> Yang
>>
>
>

Re: NettyServer multi-thread?

Posted by James Baldassari <jb...@gmail.com>.
Hi Yang,

That's correct.  The NettyServer constructor uses
Executors.newCachedThreadPool() to create a thread pool for servicing
incoming requests.  The Responder can be invoked by multiple threads from
this thread pool, so the Responder should be thread-safe.

-James


On Wed, Jun 15, 2011 at 7:29 PM, Yang <te...@gmail.com> wrote:

> I guess the answer is almost surely that Netty would start multiple threads
> to read the socket channel, just trying to confirm..
>
> when we create a NettyServer, we pass in a Single Responder. if Netty
> underneath creates many threads , the same responder (and netty handler)
> will be shared between these threads, so that I have to be careful in the
> Responder/avro handler implementation, so that it's thread-safe, right?
>
> thanks
> Yang
>