Confusion with disable fork?

In reply to Lokesh402:
Your disable fork_1; occurs after the join_any. There is nothing to disable.
See my updated model


    
    fork: fork_1
      begin
       #random_time;
       $display("process1 %t",$time);
      end
      begin
        #20;
        $error("Process 1 not completed at %t",$time);
       end

       begin #5 $display("after the #40"); end 

       begin #2 $display($stime,"\t inside the fork");
             disable fork_1; 
       end 
    // join_any
    join: fork_1
    // disable fork_1; // 
      // fork_1; //giving label name,kill all process for wenever you call and different time to call
  endtask
Sim results
# KERNEL:          2	 inside the fork
# KERNEL:          2	 out side the fork

Ben Cohen
http://www.systemverilog.us/ ben@systemverilog.us
For training, consulting, services: contact http://cvcblr.com/home.html
** SVA Handbook 4th Edition, 2016 ISBN 978-1518681448

  1. SVA Package: Dynamic and range delays and repeats SVA: Package for dynamic and range delays and repeats - SystemVerilog - Verification Academy
  2. Free books: Component Design by Example https://rb.gy/9tcbhl
    Real Chip Design and Verification Using Verilog and VHDL($3) https://rb.gy/cwy7nb
  3. Papers: