If lock is called by a thread that already owns the mutex, the behavior is undefined: for example, the program may deadlock. An implementation that can detect the invalid usage is encouraged to throw a std::system_error with error condition resource_deadlock_would_occur instead of deadlocking.
If the mutex is currently locked by the same thread calling this function, it produces a deadlock (with undefined behavior).
是个 undefined behavior ,不能这样使用,结贴😓
Reference:
https://en.cppreference.com/w/cpp/thread/mutex/lockhttps://cplusplus.com/reference/mutex/mutex/lock/