Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6596967
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:08:52+00:00 2026-05-25T18:08:52+00:00

Quick question, is the porter stemmer from Lucene packages (Java) thread safe? I’m guessing

  • 0

Quick question, is the porter stemmer from Lucene packages (Java) thread safe?

I’m guessing the answer is no as you need to set the current string, invoke stem method then get the current block to get the stemmed word. But perhaps I’m missing something – Is there are thread safe method to do stemming of a single word or string from Lucene?

Does anyone from experience know if it is faster to instantiate one Porter Stemmer instance and then use a synchronized block over that stemmer instance and do the setCurrent("..."); stem(); get(); routine or is it just faster to create a new porter stemmer instance for each string/document you want to process.

In this instance I have many 1000s of documents which are each taken up by a pool of threads (i.e. 1 thread has one document).

Edit FYI – Example usage pattern:

import org.tartarus.snowball.ext.PorterStemmer;
...
private String stem(String word){
       PorterStemmer stem = new PorterStemmer();
       stem.setCurrent(word);
       stem.stem();
       return stem.getCurrent();
    }

Cheers!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T18:08:53+00:00Added an answer on May 25, 2026 at 6:08 pm

    Looking at the docs, it seems the PorterStemmer class is not re-entrant, so I’d build an instance per thread if I were you. If stemming is one of the main things your program does, and it has no other way of keeping your CPU cores busy, then a synchronized block seems like a bad idea: the program would be blocking all the time, waiting for the stemmer to finish one document. I wouldn’t create a single thread per document, either; a thread pool with one thread per core might be a wiser choice.

    (No example code since I couldn’t even figure out the usage from the API docs. RTFS to find out how this thing works…)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Quick question. Is there an equivalent of @ as applied to strings in Java:
Quick question for everyone: Do I need to include all the database table fields
Quick question; do I always need to check for a null value after performing
Quick question here: why not ALWAYS use ArrayLists in Java? They apparently have equal
First time poster here. A quick question about setting up a loop here. I
Quick question. What do you think, I have a few sites that use a
Quick question: Would it be a good or a bad idea to implement my
Quick question: what is the compiler flag to allow g++ to spawn multiple instances
Quick question. There is a legacy website (that is not under my control and
Quick question regarding CSS and the browser. I tried searching SO and found some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.