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

Using POSIX threads & C++, I have an Insert operation which can only be
I have a Perl script that I'm attempting to set up using Perl Threads
I have a program which accepts 2 N -digit numbers, multiplies them using threads
Is OutputDebugString(PAnsiChar('')); thread safe? I/we have been using it in threads for debugging, and
Today I had to fix some older VB.NET 1.0 code which is using threads.
Sample code that shows how to create threads using MFC declares the thread function
I have a WCF service that needs to know the Principal of the calling
I have a SWT app that opens a OpenGL window (using the LWJGL library)
I have a Windows service that has a number of threads that all need
I am writing code in VS2005 using its STL. I have one UI thread

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.