# 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:** 5

<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:** [April 16, 2019, 5:00pm UTC](https://verificationacademy.com/forums/t/resume-simulation-when-any-2-threads-out-of-3-get-completed-within-fork-join-any/32572/5 "2019-04-16T17:00:51Z")

</div>

_In reply to [amiya957](https://verificationacademy.com/forums/t/resume-simulation-when-any-2-threads-out-of-3-get-completed-within-fork-join-any/32572/4):_

There are other solutions like using a simple counter, but they are not considered “_thread-safe_”. They would work fine in most situations, but the LRM does not guarantee atomic execution when multiple processes are writing to the same variable. i.e. if two process simultaneously execute N=N+1, there is no guarantee that N winds up being incremented by 2.

With today’s tools, I would say this is an impossible situation, but as your code gets more complex, and as tools adopt multi-core technologies, it could happen. So it’s better to code it the _safe_ way.

---

_[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)._
