Back to LanguageTool Homepage - Privacy - Imprint

Tip for using LanguageTool in multiple threads


(Jezparov) #1

Just wanted to post a tip: If you intend to use LanguageTool in multiple threads then be careful of using the static members of the Language class.

I have a few threads doing grammar checking. Each thread creates its own instance of JLanguageTool but I inadvertently shared an instance of the Language class between threads, which isn't thread-safe.

The fix is simple, once you know!

Change this:

langTool = new JLanguageTool(Language.AUSTRALIAN_ENGLISH);

to this:

langTool = new JLanguageTool(new AustralianEnglish());

Cheers,
Jeremy