Put a lock around the refresh method and on_render method