Could someone please help me with synchronizing varied number of threads? The problem is when the number of threads can vary from one to 9 and when for instance two clients are connected to server, the communication should be synchronized in this form : client1, client2, client1, client2 ... until the communication is over.
I tried with pthread\_join , pthread\_mutex\_lock and pthread\_mutex\_lock, but this blocks client1 until finish communicating to start client2.

Any help would be appreciated and thanks for your reply