[Interview Question] Can someone explain the output of this program?

I want to know that for the code typed below how is timing functioning? The outputs are 1,2,3. I am unable to understand how the output is getting these values.

module fork_t;
  initial begin
    for(int i=0;i<3;i++)
      begin
        //$display(i,$time);
        #1
        //$display(i);
        fork
          $display(i);
        join_none
      end
  end
endmodule

In reply to whizclips:

Please look into this thread fork-join_none with delay | Verification Academy

HTH,
-R

There are three threads being created starting at time 1 ns, 2ns, 3ns. (assuming 1ns is the timeunit)
The value of ā€œiā€ in each of the three threads is 1,2,3. Hence you are seeing the output that you are
observing.

Hope this helps

Logie Ramachandran
Verikwest Systems Inc