Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Is SAXParser in JDK6 thread-safe?

 
J Rosetto
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anyone tell me if the SAXParser in JDK 6 is thread-safe or not?

In my application I want to have a single SAXParser (configured to use a predefined set of schemas), and have several threads use it for parsing their XML.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13058
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since an SAX parser has to keep track of state and can only be attached to one input source, a single instance is NOT thread-safe.

Perhaps you were thinking of using a single instance of SAXParserFactory since it is the factory that gets configured with a schema, etc.

Bill
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic