I’d like to see some valid examples of needing to let a thread enter a locked, non-re entrant mutex, then destroying the mutex (which supposedly terminates the thread).
I can’t think of any good reason to do this. I can’t remember precisely what we were arguing about earlier today, but my colleague insists such techniques are needed for “point-of-no-return” problems (again, forgive me, but I forgot the example he gave me).
4
I suppose you could make an argument that a mutex that protects a resource should be destroyed and any waiting threads killed if something happens to the resource (e.g. threads waiting to write to a device which goes off-line). Or possibly in a hard-real-time environment where any tasks which haven’t completed during their quantum have to be force-exited. Kind of a stretch, though, I don’t see this being a general-purpose solution.
2
I think you are using your mutex as a semaphore to signal that the threads all need to shutdown. This could be useful if any one (or subset) of the threads is capable of detecting conditions that require all the other threads to stop. This would also require all the threads to routinely access this mutex & a parent thread wait for them all to terminate before terminating itself or restarting the threads.