Question on automatic/static variable behavior

Hi,
I have written following code which uses automatic variables:


class transaction;
  int x1;
  int x2;
 
  function int  add (int y);
    int tmp;
    tmp = x1 + x2 + y;
    return tmp;
  endfunction
  
  function new (int x1, int x2);
    this.x1 = x1;
    this.x2 = x2;
  endfunction

endclass

task transmit (input transaction tr, input int a);
    fork begin
        #10;
      $display ("value of x1 = %d, x2 = %d, a = %d at time %g", tr.x1, tr.x2, a, $time );
      end
    join_none
endtask

module automatic test;
  
  
  
 // transaction tr2;
 //transaction tr3;
 // transaction tr4;
  
  initial begin
    automatic transaction tr;
   
    #1 tr = new (1, 2);
    transmit (tr, 20);
    #2 tr = new (3, 4);
    transmit (tr, 30);
    #3 tr = new (5, 6);
    transmit (tr, 40);
    #20;
    
   end
  
  
endmodule

Since the module is declared as automatic and variable tr inside initial block is also automatic, I was expecting value of parameter tr and parameter a of the task transmit to be passed on the stack and values displayed should have been 1,2, 20 for first call to transmit. For second call, it should be 3, 4, 30 and for third call to transmit it should be 5, 6, 40. But simulator is displaying following values :
value of x1 = 5, x2 = 6, a = 40 at time 11
value of x1 = 5, x2 = 6, a = 40 at time 13
value of x1 = 5, x2 = 6, a = 40 at time 16

I am not able to understand this behavior. Can someone help me and explain this.
thanks and regards,
-sunil

In reply to puranik.sunil@tcs.com:

Your problem is you did not make your transmit task automatic, so its arguments tr and a are static variables. So each call to transmit overwrites the previous values. See what is the exact difference between static tasks/functions and automatic tasks/functions ? please explain with a clear example | Verification Academy