Implemented threading to handle recv without blocking the main thread