public synchronized ReadData getRead() throws IOException {
    ReadData nextRead;
    try {
      nextRead = new ReadData(reader);
    } catch (OutOfMemoryError e) {
      return null;
    }

    if (nextRead.getHeader() != null) {
      return nextRead;
    }

    return null;
  }
 public synchronized void writeRead(ReadData readData) throws IOException {
   readData.write(writer);
 }