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 5850049
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T13:05:11+00:00 2026-05-22T13:05:11+00:00

Using threads, I have a principal class ( SlaveCrawler ) that instantiates three classes(

  • 0

Using threads, I have a principal class (SlaveCrawler) that instantiates three classes(Downloader, ContentAnalyzer, URLAnalyzer) , which are dependent on each other.

SlaveCrawler uses Downloader and URLAnalyzer

Downloader uses ContentAnalyzer and URLAnalyzer

ContentAnalyzer uses URLAnalyzer

I want only one instance of each class. If I use Singleton, I can get this, but working with threads, I will have 20 SlaveCrawlers(example), so I want 20 URLAnalyzer.

It’s possible make this using Singleton or I need other way?

  • 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-22T13:05:12+00:00Added an answer on May 22, 2026 at 1:05 pm

    Take a look at ThreadLocal. Each thread will have its own local copy of each object.

    ThreadLocal<YourObject> threadLocalYourObject = new ThreadLocal<YourObject>() {
      @Override
      protected YourObject initialValue() {
        //initialize YourObject
      }
    }
    

    Or in 1.8 we can use:

    ThreadLocal<YourObject> threadLocalYourObject = ThreadLocal.withInitial( () -> new YourObject() )
    

    To get access to your ThreadLocal object, use the get() method.

    YourObject yourObject = threadLocalYourObject.get();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a program which accepts 2 N -digit numbers, multiplies them using threads
I have a Windows service that has a number of threads that all need
I have: A passive STS login application that is also an identity provider. An
I'm creating an auditting table, and I have the easy Insert and Delete auditting
I've learned that you should usually stick with either forking or threading to avoid
I have a bizarre need here, and I am unsure of it's feasibility. I
I have a WinForms app and am trying to add the ability to start
Here's what I am trying to accomplish - I have about a million files
So, I wrote a quick thread example for myself, using the ruby docs for
This is slightly related to the question asked here yet the answer does not

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.