-
Notifications
You must be signed in to change notification settings - Fork 156
Thread Safety
The parser classes created by parboiled for Java are not thread-safe. This means you have to create a separate parser instance for each thread you would like to run your parser concurrently from. However, once parboiled has extended your parser class during the initial call to Parboiled.createParser all further parser object instantiations are fast. If your application needs to regularly create a lot of parser instances you should also consider using the BaseParser.newInstance call for creating your parsers. Since this call does not use reflection for object creation it is significantly faster than Parboiled.createParser.
Since the rule tree does not hold any state during rule execution it should be concurrently usable by multiple parser instances from multiple threads, once you have a rule tree built and the root rule properly created.
Similar to the parser itself the ParseRunner implementations provided by parboiled are not threadsafe. This means that you should not use the same instance concurrently from multiple threads without synchronization. However, since ParseRunners are lightweight you can just create new instances for every parse (which is exactly what the static run(…) methods (like ReportingParseRunner.run) do).
- Introduction
- ... Motivation
- ... Features
- ... Simple Java Example
- ... Simple Scala Example
- ... RegEx vs. parboiled vs. Parser Generators
- ... Projects using parboiled
- Installation
- Concepts
- ... The Big Picture
- ... The Rule Tree
- ... The Value Stack
- ... The Parse Tree
- ... AST Construction
- ... Parse Error Handling
- parboiled for Java
- ... Rule Construction in Java
- ... Parser Action Expressions
- ... Working with the Value Stack
- ... Action Variables
- ... Parser Extension in Detail
- ... Style Guide
- ... Java Examples
- ...... ABC Grammar
- ...... Calculators
- ...... Time Parser
- ...... Java Parser
- ...... Markdown processor
- parboiled for Scala
- ... Rule Construction in Scala
- ... Parser Actions in Scala
- ... Parser Testing in Scala
- ... Scala Examples
- ...... Simple Calculator
- ...... JSON Parser
- Advanced Topics
- ... Handling Whitespace
- ... Parsing Performance Tuning
- ... Indentation Based Grammars
- ... The ProfilingParseRunner
- ... Grammar and Parser Debugging
- ... Thread Safety
- Building parboiled
- parboiled-core Javadoc API
- parboiled-java Javadoc API
- parboiled-scala Scaladoc API
- Change Log
- Patch Policy