There used to be a possible race when a bunch of rectangle is appended, but the total count is not updated before it's read. Using a lock eliminates all such races.