How to disable a random thread out of three thread which are in fork join_any block once one thread is completed

Hi ,

could you please provide the following clarifications. there is a fork join_any block.which have three threads .I need to disable any one of thread once one thread is completed . in this example let us assume thread1 is completed .I need to disable any of the thread thread2 or thread3. could you please let me know how to do it.


fork 
thread1;
thread2;
thread3;
join_any



In reply to srbeeram:

process all_forks[$], active_forks[$];
fork
   begin 
     all_forks.push_back(process::self());
     thread1;
   end
  begin 
     all_forks.push_back(process::self());
     thread2;
   end
  begin 
     all_forks.push_back(process::self());
     thread3;
   end
join_any;
foreach(all_forks[t]) if (all_forks[t].state != FINISHED) active_forks.push_back(all_forks[t];
active_forks[$urandom_range(active_forks.size-1)].kill();

Look at section 9.7 Fine-grain process control in the 1800-2017 LRM for details.