Netty Thread life cycle questions

twisti thetwister at gmx.de
Wed Apr 1 07:13:19 EDT 2009


Hello,

I'm having trouble understanding the life cycles of threads in Netty. Trying it myself is hard due to the way thread pools abstract that kind of thing away.

Here is how I believe they work:

A connection comes in. A new thread is spawned (or reused from a thread pool) to handle it's connect, despawns, and whenever a new message is received a new thread is spawned or reused. The important part here is that waiting connections that do not send or receive data do NOT occupy a thread - is that correct ? In my application, connections will typically wait around for several seconds, up to a minute, so obviously it would kill my performance if they all had threads idling around while waiting (no, sleeping threads are not free).

If that is not how it works in Netty, is there a way to make it work like that ?

What I want:

Client connects. A thread is spawned. The thread reads in the clients request. Then, a Java timer is told to send the client a reply in, say, 20 seconds. The thread despawns, or is freed or whatever, but without the connection dropping. Then, 20 seconds later, the timer thread wakes up, and spawns a new thread which will then send the reply, close the connection and despawns again.

Is this feasible ? Any ideas on how to accomplish that ?
-- 
View this message in context: http://n2.nabble.com/Netty-Thread-life-cycle-questions-tp2568438p2568438.html
Sent from the Netty User Group mailing list archive at Nabble.com.




More information about the netty-users mailing list