How to make a loop run for a specific time then switch to another loop and then back and so on

in the more general case, you might benefit from studying state machines.

Here is a small introduction to the topic: Yet another Finite State Machine introduction

and you should look at dealing with millis() if you don't want to block your code. See