# Child thread in forked foreach loop?

**URL:** <https://verificationacademy.com/forums/t/child-thread-in-forked-foreach-loop/37151>\
**Category:** SystemVerilog\
**Tags:** SystemVerilog, fork-join-in-loop\
**Created:** [February 7, 2020, 7:25pm UTC](https://verificationacademy.com/forums/t/child-thread-in-forked-foreach-loop/37151 "2020-02-07T19:25:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![runxuanl](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/runxuanl/32/3732_2.png) [@runxuanl](https://verificationacademy.com/forums/u/runxuanl)\
**Post date:** [February 7, 2020, 7:25pm UTC](https://verificationacademy.com/forums/t/child-thread-in-forked-foreach-loop/37151/1 "2020-02-07T19:25:04Z")

</div>

Consider code like this,

```verilog
  int arr[4];
  task run();
    foreach(arr[idx]) begin
      automatic int i = idx;
      fork
        begin: b1
          #i $display("%g ns, %0d", $time, i);
        end
      join_none
    end
  endtask

```

In this case, block b1 is a child thread created by fork…join\_none. I wonder since this is embed in foreach block, will that create separate thread for each loop? Is the fork…join\_none creating separate parent thread for b1 in this case?

---

<div class="post-metadata">

**Author:** ![amitgarg](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/a/c4cdca/32.png) [@amitgarg](https://verificationacademy.com/forums/u/amitgarg)\
**Post date:** [February 9, 2020, 4:08am UTC](https://verificationacademy.com/forums/t/child-thread-in-forked-foreach-loop/37151/2 "2020-02-09T04:08:27Z")

</div>

_In reply to [runxuanl](https://verificationacademy.com/forums/t/child-thread-in-forked-foreach-loop/37151):_

There will be separate thread for each b1 but all the thread will be part of main thread.  
if you plan to disable any b1 thread, it will disable all b1 thread.
