boolean (int releases) { // Decrement count; signal when transition to zero while (true) { int c = getState(); if (c == 0) return false; int next = c - 1; if (compareAndSetState(c, next)) return next == 0; } }