Skip to content

Instantly share code, notes, and snippets.

@hanbei
Last active August 29, 2015 13:59
Show Gist options
  • Save hanbei/10889616 to your computer and use it in GitHub Desktop.
Save hanbei/10889616 to your computer and use it in GitHub Desktop.
ConcurrentHashMap idioms
X x = map.get(key);
if (set == null) {
final X value = new X();
x = map.putIfAbsent(key, value);
if (x == null) {
x = value;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment