locking and realesing threat for caching return value from function