How does forever behaves in fork block

In reply to dave_59:

Hi Dave,

I have a similar question here. My requirement is like below. We have 4 DMA engines and each of them are separately. They need to do something forever in my test. Here is my code but I am not sure if it’s correct.



task my_thread();

    fork
        begin
            for (int i = 0; i < 4; i++) begin
                automatic int ii = i;
                fork
                    forever begin
                        cycle = $urandom_range(10,1000);
                        wait_cycle(cycle);
                        do something here...
                    end
                join_none
            end
            wait fork;
        end
    join

endtask : my_thread

[\systemverilog]


and I wonder how can I disable the whole thread if we reach to the end of simulation.