Five parallel thread are running after successfully execution of three i want to kill/disable rest two thread

In reply to muku_383:

Inside fork and join_none we have multiple tasks which are generally time consuming events so in that case semaphores are helpful. But in the above program if we use functions or tasks (without any delays) calls then semaphores are not helpful. Since they will executed within zero time it is not possible to handle such threads once when we call them.