Adding lock for global object count in world engine