Adding Sleep function in Ardupilot

Hello,

I designed a servo system that will drop two different weight in different waypoints.

        if (cmd.index == 1) {
            gcs().send_text(MAV_SEVERITY_INFO, " Reached waypoint 1. %d",waypoint_servoRelayEvents.do_set_servo(10, 1400));
        }
        if (cmd.index == 2) {
            gcs().send_text(MAV_SEVERITY_INFO, " Reached waypoint 2. %d",waypoint_servoRelayEvents.do_set_servo(10, 1150));
        }

The problem is I want to interrupt the code with sleep function when it reach the waypoint. But I am afraid of interrupting the code while it is flying can be dangerous. Can interrupting the code with sleep function cause a problem while its flying?

I think using multi threading for this issue is good and the thread working should be triggered to work once the particular variable is set to a value. This should do else could you elaborate more about the task or programming running in parallel/prior/after this.