Java implementation of Critical Mass