public boolean cancel () { synchronized (lock) { if (!expired) return expired = true;
public synchronized boolean cancel () { if (!expired) { return expired = true; } else {
    public boolean cancel () {      synchronized (lock) {        if (!expired)          return expired = true;        return false;      }    }