Jsoup thread security

Jsoup parse(String html) not supported in streaming mode. How do you process multiple documents at once with Jsoup? Thanks

+6
source share
3 answers

Using Joup.parse .

While you are not working on the same document, it creates a new object inside.

https://groups.google.com/forum/?fromgroups=#!topic/jsoup/QIij7DEhj8E

This occurs from time to time; probably worth pointing out a problem with the documentation.

+6
source

Looking at the source code of Jsoup.java , it has no state, and both parse () methods pass Parser.parse () , which internally creates and delegates TreeBuilder.parse () . Both Jsoup and Parser classes are stateless and contain only static methods. The TreeBuilder class has a state and seems to do all the work, but is created from a method, so the whole operation is thread safe due to stack / thread limitations.

+4
source

Just add to the previous answer from empirical data: we used JSoup 1.6.1 with 20 queries per second during the performance test without any adverse results.

+2
source

All Articles