Modification () { Modification modification = new Modification(); if (myCurrentModification.compareAndSet(null, modification)) { return modification; } throw new RuntimeException("Can not start a new modification while the other one is still running."); }