Fixed infinite loop that may occur in case an InterruptedExceptin is thrown while reading data using a thread.