Originally Posted by
gdev
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.
public void writeReportLine(Element rptLine) {
[...]
}
After all priocessing completes, the below method is called only once by every thread to write to the File on the file system:
public void writeToReportFile() {
[...]
}
Is the writeToReportFile() method called only once after processing from all the threads (that call writeReportLine() to build up reportOutput) completes? I'm asking because you wrote, "[writeToReportFile()] is called only once by every thread [...]." To put this in another way, is the method called once for each of the thread, or once for all the threads?
Originally Posted by
gdev
The problem is that when under load, the threads just seem to hang while the transformer.transform(source, result) call keeps getting executed until there is an interrupt of some sort. I was able to examine a section of what was appended and it was status for records that had finished processing very early in the process based on my application logs.
By "transformer.transform(source, result) call keeps getting executed", do you mean that the transform() method is being called repeatedly, which would suggest that writeToReportFile() is being called repeatedly?
To further diagnose this, get a thread dump when the problem occurs. On Unix/Linux, a
kill -quit <java_pid> would suffice. On Windows (also on Unix/Linux), use
jstack. Before you do that, it'll help to name the threads (e.g., create your
Threads using the
Thread(String name) constructor) to make them more easily identifiable in the thread dump. Once you have the thread dump, you can either eyeball it, or use a tool such as
https://java.net/projects/tda or
https://www.ibm.com/developerworks/c...1-14c205f7333c (I usually use the latter) to help analyse it.