Chapter 7. EventLoop and threading model

This chapter covers

  • Threading model overview
  • Event loop concept and implementation
  • Task scheduling
  • Implementation details

Simply stated, a threading model specifies key aspects of thread management in the context of an OS, programming language, framework, or application. How and when threads are created obviously has a significant impact on the execution of application code, so developers need to understand the trade-offs associated with different models. This is true whether they choose the model themselves or acquire it implicitly via the adoption of a language or framework.

In this chapter we’ll examine Netty’s threading model in detail. It’s powerful but easy to use and, as usual with Netty, aims to simplify your application code and maximize performance and maintainability. We’ll also discuss the experiences that led to the choice of the current model.

If you have a good general understanding of Java’s concurrency API (java.util.concurrent), you should find the discussion in this chapter straightforward. If you’re new to these concepts or need to refresh your memory, Java Concurrency in Practice by Brian Goetz, et al. (Addison-Wesley Professional, 2006) is an excellent resource.

7.1. Threading model overview

In this section we’ll introduce threading models in general and then discuss Netty’s past and present threading models, reviewing the benefits and limitations of each.

7.2. Interface EventLoop

7.3. Task scheduling

7.4. Implementation details

7.5. Summary

sitemap