You might get some ideas from testing Simple threaded chat server. It has a simple method for making the chat echo to all clients, and you can probably modify it for your purposes manipulating the @clients list, or splitting @clients into 2, @clients1 and @clients2. It's not bulletproof code, but does demonstrate the flow thru threads.