How to disable fork join or fork join_any after executed particular thread or process, please look at example

How to disable fork join or fork join_any after executed particular thread or process

Ex: Requirement: Need to disable fork join after executing join_2 thread or process
Please help me in this

module fork_join;
 
  initial begin
    
    $display("**********BEFORE FORK..JOIN**********");
    
    fork
      begin:join_1
        #1 $display($time,"\tThread A");
        #2  $display($time,"\tThread B");
      end
      begin: join_2
        #2 $display($time,"\tThread C");
        #3  $display($time,"\tThread D");
      end
      
      begin:join_3
        #5 $display($time,"\tThread E");
        #6  $display($time,"\tThread F");
      end
    join
    
    #7  $display($time,"\tThread G");
 
    $display("**********AFTER FORK..JOIN**********");
    
    $finish;
  end
  
endmodule

In reply to Subbi Reddy:

It’s not really clear what you want to accomplish. Maybe something like:


module fork_join;
  event j2_e;
  
  initial begin
    
    $display("**********BEFORE FORK..JOIN**********");
    
    fork: main_join
      begin:join_1
        #1 $display($time,"\tThread A");
        #2  $display($time,"\tThread B");
      end
      begin: join_2
        #2 $display($time,"\tThread C");
        #3  $display($time,"\tThread D");
        ->j2_e;
      end
      begin:join_3
        #5 $display($time,"\tThread E");
        #6  $display($time,"\tThread F");
      end
    join_none
    
    wait (j2_e);
    
    disable main_join;
    
    #7  $display($time,"\tThread G");
 
    $display("**********AFTER FORK..JOIN**********");
    
    $finish;
  end
  
endmodule

In reply to cgales:

In Mentor graphics is executed successfully

I am getting an error when executing in synopsys and cadence
Error: wait (j2_e);An event is not a legal rvalue in this context [9.7.3(IEEE)]

please help me to overcome this issue in cadence

In reply to Subbi Reddy:


module fork_join;
  event j2_e;
 
  initial begin
 
    $display("**********BEFORE FORK..JOIN**********");
 
    fork: main_join
      begin:join_1
        #1 $display($time,"\tThread A");
        #2  $display($time,"\tThread B");
      end
      begin: join_2
        #2 $display($time,"\tThread C");
        #3  $display($time,"\tThread D");
        ->j2_e;
      end
      begin:join_3
        #5 $display($time,"\tThread E");
        #6  $display($time,"\tThread F");
      end
    join_none
 
    @j2_e;
 
    disable main_join;
 
    #7  $display($time,"\tThread G");
 
    $display("**********AFTER FORK..JOIN**********");
 
    $finish;
  end
 
endmodule

In reply to Subbi Reddy:

On EDA Playground, 3 out of the 4 simulators function as expected. One does not. You will need to work with your EDA vendor to determine the issue.

In reply to cgales:

In reply to Subbi Reddy:
On EDA Playground, 3 out of the 4 simulators function as expected. One does not. You will need to work with your EDA vendor to determine the issue.

Thank you cgales