Activator Template of the Month: Two for One!
This month we are featuring two related Activator Templates of the Month related by purpose but divided by language.
Akka FSM in Scala and Akka FSM in Java with Lambdas both demonstrate an implementation of the Dining Philosophers problem used to demonstrate concurrency issues in computer science. The idea is that a number of philosophers are sitting around a table and food is delivered. The same number of forks (or chopsticks) are available as philosophers, but a philosopher needs 2 forks (or chopsticks) to eat. If all plates happen to be delivered at the same instant and all philosophers reach for their right fork first, then hold on to it while waiting for the left to be available, then there is a race condition that leads to all of the developers starving while waiting for two forks. It’s a heartwarming story about how stubborn philosophers are, and how the world needs more forks and chopsticks :-), no actually it’s a good example of race conditions and strategies for avoiding them.
These two templates use the FSM (Finite State Machine) features in akka to explore the problem in both Scala and Java.