In reply to rgarcia07:
Many thanks for your comments about the wait fork; I like it.
On a separate thought, I figured out why the “j” in the following code is 10 and why I need the “k”.
task automatic t();
for (int j = 0; j <= 9; j++) begin
int k = j;
// #10;
fork
begin
$display("j %0d k %0d ",j,k);
A(j); // A(k);
end
join_none
end
endtask
It’s because “j” acts like a local variable and all these A(j) task calls get pushed into a queue.
When they get processed they use the current value of “j” that is now 10.
One would have thought that the value would have been the value of “j” in the loop cycle it was
initiated.