main server with threads