Most likely, this was done to facilitate the execution of the example, allowing the mutex itself to be used as the focus of the example, rather than the exact specification.
Typically, a mutex protects a resource, and in many cases it makes sense for a mutex to live with a resource. For example, if you have a class with a member container that must be protected by a mutex, make the mutex also a member of the class. Then, when an instance of the class acts on multiple threads, the mutex member can be used to protect the necessary accesses to the internal container.
source share