<div dir="ltr"><div>You're right! I can limit the number of thread to one using the second constructor and sending 1 to workerCount.</div>
<div><a href="http://docs.jboss.org/netty/3.2/api/org/jboss/netty/channel/socket/nio/NioServerSocketChannelFactory.html#NioServerSocketChannelFactory(java.util.concurrent.Executor, java.util.concurrent.Executor, int)"><strong><font face="Courier New">NioServerSocketChannelFactory</font></strong></a><font face="Courier New">(</font><a title="class or interface in java.util.concurrent" href="http://java.sun.com/javase/6/docs/api/java/util/concurrent/Executor.html?is-external=true"><font face="Courier New">Executor</font></a><font face="Courier New"> bossExecutor, </font><a title="class or interface in java.util.concurrent" href="http://java.sun.com/javase/6/docs/api/java/util/concurrent/Executor.html?is-external=true"><font face="Courier New">Executor</font></a><font face="Courier New"> workerExecutor, int workerCount)</font> </div>
<div> </div>
<div>(I can also use the Executors.newSingleThreadExecutor() only if workerCount equals 1, but as you say it's not necessary)</div>
<div> </div>
<div>Thanks!<br><br></div>
<div class="gmail_quote">On Thu, Nov 25, 2010 at 12:21 PM, Christian Migowski <span dir="ltr"><<a href="mailto:chrismfwrd@gmail.com">chrismfwrd@gmail.com</a>></span> wrote:<br>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">I haven't used Executors.newSingleThreadExecutor() in my own code, why<br>don't you try<br><br> new NioServerSocketChannelFactory(<br>
Executors.newCachedThreadPool(),<br> Executors.newCachedThreadPool()));<br><br>as most of the Netty examples do? That definitively doesn't create a<br>thread per connection and also handles lot of concurrent connections<br>
just fine.<br>I think you should read the javadoc, it is all explained very nicely<br>in there [1].<br><br>hth,<br>christian!<br><br>[1] <a href="http://docs.jboss.org/netty/3.2/api/org/jboss/netty/channel/socket/nio/NioServerSocketChannelFactory.html#NioServerSocketChannelFactory(java.util.concurrent.Executor" target="_blank">http://docs.jboss.org/netty/3.2/api/org/jboss/netty/channel/socket/nio/NioServerSocketChannelFactory.html#NioServerSocketChannelFactory(java.util.concurrent.Executor</a>,<br>
java.util.concurrent.Executor)<br>
<div class="im"><br><br><br><br>On Thu, Nov 25, 2010 at 9:46 AM, hada <<a href="mailto:hadassa.koen@gmail.com">hadassa.koen@gmail.com</a>> wrote:<br>><br>> OK. I will precise my question:<br>> if you define the NioServerSocketChannelFactory as<br>
> new<br>> NioServerSocketChannelFactory(Executors.newSingleThreadExecutor(),Executors.newSingleThreadExecutor()),<br>> only one workerThread will be created.<br>> Say that the client sends "Hello, I'm client" message and the server<br>
> responds with a "hello, I'm server" and then the client re-send "Hello, i'm<br>> client" etc....<br>> for the first client this message exchange happens, but no for a second<br>> client. This is because only a single thread is allowed for workerThread in<br>
> NioServerSocketChannelFactory.<br>> Only when the first client will be disconnected, the second one will<br>> "receives" the thread, and then the message exchange will start.<br>> (however, in the netstat i see that the connection is established for the 2<br>
> clients, although only the first client is 'active')<br>><br>> What I want is that only one thread will be manage the exchange message for<br>> many connections!<br>><br>><br>><br>> --<br>
</div>> View this message in context: <a href="http://netty-forums-and-mailing-lists.685743.n2.nabble.com/How-to-define-one-thread-for-multiple-connections-tp5773292p5773426.html" target="_blank">http://netty-forums-and-mailing-lists.685743.n2.nabble.com/How-to-define-one-thread-for-multiple-connections-tp5773292p5773426.html</a><br>
<div>
<div></div>
<div class="h5">> Sent from the Netty User Group mailing list archive at Nabble.com.<br>> _______________________________________________<br>> netty-users mailing list<br>> <a href="mailto:netty-users@lists.jboss.org">netty-users@lists.jboss.org</a><br>
> <a href="https://lists.jboss.org/mailman/listinfo/netty-users" target="_blank">https://lists.jboss.org/mailman/listinfo/netty-users</a><br>><br>_______________________________________________<br>netty-users mailing list<br>
<a href="mailto:netty-users@lists.jboss.org">netty-users@lists.jboss.org</a><br><a href="https://lists.jboss.org/mailman/listinfo/netty-users" target="_blank">https://lists.jboss.org/mailman/listinfo/netty-users</a><br></div>
</div></blockquote></div><br></div>