Questionable use of Double Checj
class QuestionableUseOfDoubleCheck { | |
private long firstAccess = -1; | |
public long accessSomething() { | |
if (firstAccess != -1) { | |
return this.firstAccess; | |
} | |
synchronized (this) { | |
if (this.firstAccess != -1) { | |
return this.firstAccess; | |
} | |
this.firstAccess = System.currentTimeMillis(); | |
return this.firstAccess; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment