I think newSize should probably be an atomic int with an atomic increment. AFAICT there shouldn't be a race condition here, but it'd make this more robust in the face of future refactoring.