Introduction to Event-Based Concurrency
This lesson presents a gentle introduction to a completely different paradigm of concurrency, event-based concurrency.
Thus far, we’ve written about concurrency as if the only way to build concurrent applications is to use threads. Like many things in life, this is not completely true. Specifically, a different style of concurrent programming is often used in both
The problem that event-based concurrency addresses is two-fold.
- The first is that managing concurrency correctly in multi-threaded applications can be challenging; as we’ve discussed, missing locks, deadlock, and other nasty problems can arise.
- The second is that in a multi-threaded application, the developer has little or no control over what is scheduled at a given moment in time; rather, the programmer simply creates threads and then hopes that the underlying OS schedules them in a reasonable manner across available CPUs.
Given the difficulty of building a general-purpose scheduler that works well in all cases for all workloads, sometimes the OS will schedule work in a manner that is less than optimal. And thus, we have event-based concurrency.
THE CRUX: HOW TO BUILD CONCURRENT SERVERS WITHOUT THREADS
How can we build a concurrent server without using threads, retain control over concurrency, and avoid some of the problems that seem to plague multi-threaded applications?
Get hands-on with 1400+ tech skills courses.