Run generator in parallel

I want to run N generator, driver, monitor, model and scoreboard in parallel. ( there are N independent lines)
How to write its code in the environment class? I tried to use for and fork-join but it doesn’t get the right answer.

 for(int i=0; i< N; i++)
                     automatic int k=i;

In reply to Moein75:

What do you mean by “doesn’t get the right answer”? Does it not compile? Does it not run? Does it run but not meet your requirements?

A complete example would be very helpful.

It runs but does not meet my requirements.
As soon as one statement in fork-join
-any has run, the simulator runs lines after join_any and I don’t get desired output.
If I change fork-join_any, with fork-join, It stays in the loop forever. Because in the driver we have a forever loop.

In reply to Moein75:

So you will need to look at each component and determine how you want to start it.
For a component which has a forever loop and never returns, or if you don’t care when it returns, you want to use a fork/join_none.
For a component which does return, you need to determine if you want to wait for just one to finish (fork/join_any), or wait for all to return (fork/join).

You will need to a for loop for each scenario.