public void Depart () { while (true) { int x = var; short c, v; Decode (x, out c, out v); if (Interlocked.CompareExchange (ref var, Encode ((short)(c - 1), v), x) == x) { if (c == 1) parent.Depart (); return; } } }