Jsoup parse(String html) is not ducumented as thread safe. How do you parse multiple documents with Jsoup concurrently? Thanks
By using Joup.parse.
As long as you're not working on the same document, it creates new object internally.
https://groups.google.com/forum/?fromgroups=#!topic/jsoup/QIij7DEhj8E
This comes up from time to time; it's probably worth filing a documentation issue against this.
Looking at the Jsoup.java source code it doesn't have any state and both parse() methods are delegating to Parser.parse() that is internally creating and delegating to a TreeBuilder.parse(). Both Jsoup and Parser classes have no state and are only holding static methods. TreeBuilder class though has a state and seems to be doing all the work but it's created from within a method therefore the whole operation is thread-safe by virtue of stack/thread confinement.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With