Fix ThreadCachedInt race condition