Disable fork join when one of the tasks complete

In reply to saritr:
Having nested
forever
loops does not make much sense. Normally you put
disable fork
after a
join_any
. Doing that with your example would not disable the process calling the monitor_cycle_count() because it is a sibling to the thread doing the disable, not a child of it.

Maybe you intended to write

virtual task run_phase (uvm_phase phase);
forever begin
          mon_trx = axi_transaction::type_id::create("mon_trx");
          fork 
            monitor_cycle_count();
          join_none
          fork
            monitor_write();
            monitor_read();                 
          join_any;
          disable fork;
      end
  endtask: run_phase

The
disable fork
above will wait for one of the monitor_read/write tasks to finish, then kill the other one as well as killing the monitor)cycle_count task if it is still running. It was not very clear what your intention was.