# Resume simulation when any 2 threads out of 3 get completed within fork-join\_any

**URL:** <https://verificationacademy.com/forums/t/resume-simulation-when-any-2-threads-out-of-3-get-completed-within-fork-join-any/32572>\
**Category:** SystemVerilog\
**Tags:** fork-join\_any, SystemVerilog\
**Created:** [November 19, 2016, 8:19am UTC](https://verificationacademy.com/forums/t/resume-simulation-when-any-2-threads-out-of-3-get-completed-within-fork-join-any/32572 "2016-11-19T08:19:55Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![dave\_59](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/dave_59/32/4499_2.png) [@dave\_59](https://verificationacademy.com/forums/u/dave_59)\
**Post date:** [November 19, 2016, 4:19pm UTC](https://verificationacademy.com/forums/t/resume-simulation-when-any-2-threads-out-of-3-get-completed-within-fork-join-any/32572/2 "2016-11-19T16:19:42Z")

</div>

_In reply to [Sagar Shah](https://verificationacademy.com/forums/t/resume-simulation-when-any-2-threads-out-of-3-get-completed-within-fork-join-any/32572):_  
You can use a semaphore that waits for 2 keys

```verilog
semaphore s;

s = new(0);
fork
   begin : process1
    ...
    s.put(1);
   end
 begin : process2
    ...
    s.put(1);
   end
 begin : process3
    ...
    s.put(1);
 end
join_none
s.get(2);
disable fork; // kills remaining process
s = null; // removes semaphore (if you plan to reuse s)

```

---

_[View the full topic](https://verificationacademy.com/forums/t/resume-simulation-when-any-2-threads-out-of-3-get-completed-within-fork-join-any/32572)._
