Thread-based implementation of a simple server