<div dir="ltr"><div>You&#39;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&#39;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">&lt;<a href="mailto:chrismfwrd@gmail.com">chrismfwrd@gmail.com</a>&gt;</span> wrote:<br>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">I haven&#39;t used Executors.newSingleThreadExecutor() in my own code, why<br>don&#39;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&#39;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 &lt;<a href="mailto:hadassa.koen@gmail.com">hadassa.koen@gmail.com</a>&gt; wrote:<br>&gt;<br>&gt; OK. I will precise my question:<br>&gt; if you define the NioServerSocketChannelFactory as<br>
&gt; new<br>&gt; NioServerSocketChannelFactory(Executors.newSingleThreadExecutor(),Executors.newSingleThreadExecutor()),<br>&gt; only one workerThread will be created.<br>&gt; Say that the client sends &quot;Hello, I&#39;m client&quot; message and the server<br>
&gt; responds with a &quot;hello, I&#39;m server&quot; and then the client re-send &quot;Hello, i&#39;m<br>&gt; client&quot; etc....<br>&gt; for the first client this message exchange happens, but no for a second<br>&gt; client. This is because only a single thread is allowed for workerThread in<br>
&gt; NioServerSocketChannelFactory.<br>&gt; Only when the first client will be disconnected, the second one will<br>&gt; &quot;receives&quot; the thread, and then the message exchange will start.<br>&gt; (however, in the netstat i see that the connection is established for the 2<br>
&gt; clients, although only the first client is &#39;active&#39;)<br>&gt;<br>&gt; What I want is that only one thread will be manage the exchange message for<br>&gt; many connections!<br>&gt;<br>&gt;<br>&gt;<br>&gt; --<br>
</div>&gt; 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">&gt; Sent from the Netty User Group mailing list archive at Nabble.com.<br>&gt; _______________________________________________<br>&gt; netty-users mailing list<br>&gt; <a href="mailto:netty-users@lists.jboss.org">netty-users@lists.jboss.org</a><br>
&gt; <a href="https://lists.jboss.org/mailman/listinfo/netty-users" target="_blank">https://lists.jboss.org/mailman/listinfo/netty-users</a><br>&gt;<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>