The thing is that with semaphore I can control what thread begins first but with mutex I don't know how I can do it.
I have two threads:
The first thread is the main function, so it starts first. Than it creates another thread. Afterwards the first thread must sleep 2 seconds because the thread 2 must open a connection and then both have a wait for the mutex. I wanted that thread 1 takes the mutex before. I wanted to know how can I do it.
|
is it possible that thread one first take the mutex and then second thread is created??