문제

When profiling my application, I noticed that creating instances of XMLInputFactory over and over is very expensive. Is it safe to share its instances across multiple threads?

The javadoc doesn't say anything about its thread-safety and searching the internet doesn't give a definite answer!

도움이 되었습니까?

해결책

I have decided to use Woodstox as the StAX implementation. It is both much faster than the default JDK implementation and explicitly mentions thread safety.

Woodstox factories are thread-safe after configuration phase (calling setProperty()), but not during it. Most importantly, once all configuration is done, calling 'createXMLxxx' methods is fully thread-safe.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top