Skip to content

Is LanguageDetector thread-safe? #277

Answered by pemistahl
Vasniktel asked this question in Q&A
Discussion options

You must be logged in to vote

Yes, it is thread-safe. Otherwise, the parallel variants of the LanguageDetector methods would not work because they do exactly that, namely sharing the same instance across multiple threads.

In order to make the library thread-safe, the only thing necessary was to wrap the HashMaps which hold the language models in RwLocks.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Vasniktel
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #275 on November 27, 2023 18:22.