"deactivation" says "// start a timer to "suggest" a deactivate to self and neighbors."
Why does activation setActive then? It's basically the same method but only a different Config.
So basically setActive can be removed from "startActivation()" method.
Because else it's just a duplication? (not optimized)
EDIT:
Why don't you replace both methods with just one?
Remove startActivation() && startDeactivation()
Code: Select all
/** * This method will switch activation of a region * @param activation */private void switchActive(){ boolean _activation = isActive() ? false : true; synchronized (this) { if(_neighborsTask != null) { _neighborsTask.cancel(true); _neighborsTask = null; } _neighborsTask = ThreadPoolManager.getInstance().scheduleGeneral(new NeighborsTask(_activation), 1000 * (_activation ? Config.GRID_NEIGHBOR_TURNON_TIME : Config.GRID_NEIGHBOR_TURNOFF_TIME)); }}