1
我將創建一個類,它應該解開非常大的xml文件。Java JAXB多線程解組
我實現了一般解組:
public XMLProcessor(XMLFile file) throws JAXBException, IOException, SAXException {
JAXBContext jc = JAXBContext.newInstance(Customers.class);
Unmarshaller unmarshaller = jc.createUnmarshaller();
File xml = new File(file.getFile().getOriginalFilename());
file.getFile().transferTo(xml);
this.customers = (Customers) unmarshaller.unmarshal(xml);
}
它工作正常,但花了一分多鐘的過程1萬個客戶XML。
我可以通過創建多個線程並同時解組XML文件的幾個部分來提高性能嗎?
我應該如何將XML文件分成幾部分?
您能告訴我一些我的案例的示例代碼嗎?
我放棄了使用SAX的想法。相反,我生成了一些適當的JAXB註釋類,而解組器的速度令人印象深刻。 1.6GB在沒有任何多線程的情況下在40秒內得到解組。這對我的情況來說已經足夠了 – cgicgi