public class AsynchCon extends Prisoner { private boolean haveTurnedLightOn; private int count; public AsynchCon(int ID) { super(ID); haveTurnedLightOn = false; } public String strategyDescription() { return "Everyone turns on light exactly once; Only P0 turns it off."; } public boolean visit(int day, LightBulb light) { if (!haveTurnedLightOn && light.isOff()) { light.turnOn(); this.haveTurnedLightOn = true; } if (ID == 0 && light.isOn()) { this.count++; light.turnOff(); if (this.count == Warden.SIZE) return true; } return false; } }