Skip to content

Instantly share code, notes, and snippets.

@prydin

prydin/DoubleCheck.java

Last active Dec 19, 2019
Embed
What would you like to do?
Typical double check
class DoubleCheck {
private SomeResource myResource;
public SomeResource getResource() {
if(myResource != null) {
return myResource
}
synchronized(this) {
if(myResource != null) {
return myResource
}
myResource = new SomeResource();
return myResource
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.