When I have three threads or more, if mutex unlock in one thread, which one will be the next to process? They are in FIFO rule? If not FIFO, several thread wait unlock(), will have a thread never process? Do they wait in a sorted queue and what is the rule to sort them?
Sample code:
//thread No.1
func1(){
std::unique_lock<mutex> lock(_mtx);
//do something, now in here,and will leave this thread then mutex will unlock
}
//thread No.2
func2(){
std::unique_lock<mutex> lock(_mtx);
//do something
}
//thread No.3
func3(){
std::unique_lock<mutex> lock(_mtx);
//do something
}