Skip to content

Instantly share code, notes, and snippets.

@wburns
Last active September 4, 2015 16:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wburns/dc5e78dbd7d0635e939a to your computer and use it in GitHub Desktop.
Save wburns/dc5e78dbd7d0635e939a to your computer and use it in GitHub Desktop.
Integer counter = cache.get(key);
while (true) {
if (counter != null && cache.replace(key, counter, counter + 1) {
break;
}
if (counter == null && cache.putIfAbsent(key, 1) == null) {
break;
}
counter = cache.get(key);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment