How about:
Thread 1:
while (!stop)
{
AutoLock addLock(_addLock);
AutoLock socLock(_socketsLock);
// Release the addLock here.
// This gives thread 2 an opportunity to get the first lock while this
// thread is waiting on the socket.
AutoRelease addRel(addLock);
// When this thread finishes it will be forces to sleep if there are
// any waiting AddSocket requests otherwise it will continue as normal.
Socket* activeSockets = waitOnSockets(_sockets, 50);
}
Thread 2:
void AddSocket(Socket* socket)
{
AutoLock addLock(_addLock);
AutoLock socLock(_socketsLock);
_sockets.push_back(socket);
}