Flavours of Concurrency in Java


Software has evolved so much that single threaded programs are rarely enough now. In this talk we’ll cover several approaches to organising your concurrent Java code: from managing threads to actor frameworks, to software transactional memory. Writing concurrent code that is also correct is unbelievably hard. Naturally, humanity has developed a number of approaches to handle concurrency in the code, starting from basic threads that follow the hardware way to do concurrency to higher level primitives like fibers and work-stealing solutions. But which approach is the best for you? In this session, we’ll take a look at a simple concurrent problem and solve it using different ways to manage concurrency: threads, executors, actors, fibers, monadic code with completable futures. All these approaches are different from the simplicity, readability, configuration and management point of view. Some scenarios are better modeled with threads, while sometimes you’re better off with actors. We’ll discuss the benefits of each approach and figure out when it’s worth pursuing in your project.