concept Thread in category netty

appears as: Thread
Netty in Action

This is an excerpt from Manning's book Netty in Action.

This code will handle only one connection at a time. To manage multiple, concurrent clients, you need to allocate a new Thread for each new client Socket, as shown in figure 1.1.

Because computers with multiple cores or CPUs are commonplace, most modern applications employ sophisticated multithreading techniques to make efficient use of system resources. By contrast, our approach to multithreading in the early days of Java wasn’t much more than creating and starting new Threads on demand to execute concurrent units of work, a primitive approach that works poorly under heavy load. Java 5 then introduced the Executor API, whose thread pools greatly improved performance through Thread caching and reuse.

Asynchronous implementations use only a few EventLoops (and their associated Threads), and in the current model these may be shared among Channels. This allows many Channels to be served by the smallest possible number of Threads, rather than assigning a Thread per Channel.

Figure 7.4 displays an EventLoopGroup with a fixed size of three EventLoops (each powered by one Thread). The EventLoops (and their Threads) are allocated directly when the EventLoopGroup is created to ensure that they will be available when needed.