finish thread if receives message with 0 bytes (signal of client disconnected). uses mutex to use search method safely