In the early days of ANTLR 4 (a few months before its initial release), an adaptive DFA cache was created based on each instance, so using Lexer.setInputStream or Parser.setInputStream was necessary to achieve good performance.
This is no longer the case. The background cache is now shared between all instances of the parser and is thread safe. Lexer and Parser class methods are not thread safe, so if you want to analyze multiple threads, you will need to create multiple instances of your lexer and parser.
Sam harwell
source share