You can't control the threads directly (tell the system: now run that thread). But you can have nearly the same result when you use mutexes or semaphores. Semaphores (in general, mutexes can be threated like semaphores) allow only a certain number of threads to run. For example, if a semaphore allows only 3 processes to go, when the fourth one tries to pass, it's stopped until one of the three releases the semaphore. I'm not trying to explain semaphores here, because books are written about them.
In your situation, the following scheme should be Ok:
Code:
thread_1 thread_2 thread_3
running
m1.up()
completed running
m2.up()
completed
running
The initial state is that m1 and m2 are set to 0 (a thread must wait until the up() operation is performed).