How to control the flow when multiple threads are running

You can’t control, nor should you depend on the order of parallel threads synchronized to the same event (@posedge clk). You don’t show how q_in[index] gets modified, but if they are all at time 0, there’s also no guarantee about the ordering before the delay either.

If you require a particular execution ordering, then you should not be using parallel threads, or you need to use a semaphore/mailbox that guarantees FIFO thread ordering. I would need to know more about what you are trying to accomplish and the reasoning behind your requirements to suggest an alternative.