Results 1 to 2 of 2
- 05-21-2014, 06:35 PM #1
Member
- Join Date
- May 2014
- Posts
- 1
- Rep Power
- 0
Problem with use of Multi threading with DOM object
My multi threaded application processes and loads records into an ECM repository. For reconcliation purposes , I am trying to build an XML format report with the results of the processing per record, while processing is underway per thread. The method below is called from every thread wvery time its ready to append an element to the DOM with the status.
Java Code:public void writeReportLine(Element rptLine) { // Write output to report file synchronized (XMLReportHandler.class) { reportOutput.getDocumentElement().appendChild(rptLine); } }
Java Code:public void writeToReportFile() { synchronized (XMLReportHandler.class) { try{ //write the content into xml file TransformerFactory transformerFactory = TransformerFactory.newInstance(); Transformer transformer = transformerFactory.newTransformer(); DOMSource source = new DOMSource(reportOutput); StreamResult result = new StreamResult(f); transformer.transform(source, result); }catch(TransformerConfigurationException e){ logger.error("** Error getting xml report document object: " + e); e.printStackTrace(); }catch(TransformerException e){ logger.error("** Error getting xml report document object: " + e); e.printStackTrace(); } } }
Any idea whats wrong in here ? Thanks in advance for your advice - I have been stuck trying to figure out where the problem out for days! Now that I know where the problem is , I cant figure out a solution. Looking for multi threading gurus..
- 05-21-2014, 08:59 PM #2
Re: Problem with use of Multi threading with DOM object
Also posted at: Building DOM object from multiple threads
If you don't understand my response, don't ignore it, ask a question.
Similar Threads
-
Multi-threading Problem with Console Input and Output
By racnil in forum New To JavaReplies: 4Last Post: 11-27-2012, 12:07 PM -
Multi-Threading
By TonyDaniels in forum New To JavaReplies: 4Last Post: 03-09-2012, 07:16 PM -
Multi-Threading
By TonyDaniels in forum Advanced JavaReplies: 1Last Post: 03-09-2012, 06:52 PM -
multi-threading problem
By imorio in forum New To JavaReplies: 1Last Post: 04-25-2011, 07:52 PM -
Problem in Multi threading.
By Chetans in forum Advanced JavaReplies: 3Last Post: 03-23-2010, 05:42 PM
Bookmarks