Updated the multithreaded environment

Master and worker are now multithreaded, one thread per connection.
They listen to each other on a loop until the closeConnection command is
issued to them.