$urandom_range() inside for fork-join loop

Hi

I have the below code -

for (int i = 0; i < NUM_INST; i++) begin 
  automatic int j=i;
  fork 
  // task using using $urandom_range(1,4);
  join_none
end

Is it assured that every thread forked out will have random values between 1 to 4 in any order ?

Is there a better way to implement this ?

Explain in more detail what you mean by “better”.

Perhaps show us minimal, complete reproducible example with results expect.

Just want to ensure the given code will execute $urandom_range in every thread independently

Yes. $urandom uses a seed (RNG) from the process of execution, and each forked process uses an RNG from the parent process.