In reply to amiya957:
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.