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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:40:49+00:00 2026-05-23T11:40:49+00:00

Right now I have a program with a Gui that indexes a url that

  • 0

Right now I have a program with a Gui that indexes a url that I specify. I need to index 15 things at a time and I have been just opening 15 windows of the program and individually inputting the urls that i want to index. However these 15 url’s change every hour or so… I have a separate program that stores these 15 constantly changing urls in a table in my mysql database. I am able to fetch these urls from my database(I store them in an arraylist) but im not sure how to go about multi-threading my application so that i dont have to do the manual work of inputing the urls into my application.

My question: Can someone give me an example/link me to a tutorial of how I would go about creating a new thread for each url in my arraylist(also this arraylist will change so will i need to make a new thread for changing this arraylist aswell?)

Ive looked at the java site on concurrency and high level concurrency but didn’t really understand the examples they gave(I am still a beginning programmer so please bear with me)

Hopefully I explained what im trying to do with enough detail
Thanks in advance

EDIT: The urls i index change every couple of seconds which is why i dont think i can go through my method with each url one after another, hence why i believe it needs to be multithreaded?

2nd EDIT(I believe these guys understand what im asking):

@Jon Storm There are two issues going on 1) Getting URL list 2) Accessing said URLs. I would make the URL fetcher single-threaded and then dispatch out to a Thread Pool of fetchers. This dispatcher can also queue pending fetches, etc. – pst

@Jon Storm: could you please update your question to describe what you want to do more explicitely? If In understood correctly, you want to index a list of 15 URLs again and again, because the contents of the pages at these URLs changes every 3 seconds. And you want to update the list of URLs to index every hour, by getting them from a database. Is that right? – JB Nizet

  • 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-23T11:40:50+00:00Added an answer on May 23, 2026 at 11:40 am

    It seems to me that your problem is not with multi-threading, but with inputting something in a GUI from the application fetching the URLs from the database.

    Why don’t you simply reuse the class (or some of the code, if it’s impossible to reuse the classes as is) of your GUI application (i.e. the URL indexing method) inside the application which fetches the URLs from the database.

    My guess is that you could very well index these 15 URLs one after the other, in a single thread. I would try doing that before trying to use threads.

    The program would look like this:

    1. Fetch the 15 URLs from the database and put them into a List
    2. Iterate through the list and index each URL
    3. Sleep for some time,
    4. Go to 1

    EDIT:

    Since it seems the URLs must be indexed again and again until the list of URLs changes, I would use this algorithm:

    1. Create a thread pool using Executors.newCachedThreadPool()
    2. Get the URLs from the database
    3. For each URL, create a task which will index the URL again and again, until interrupted (check that Thread.interrupted() returns false at each iteration)
    4. submit each task to the executorService created at step 1, and keep the returned Future inside a list
    5. Sleep/wait until the list of URLs to index changes
    6. Cancel each Future (cancel(true)) of the list of Future instances
    7. Go to step 2.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So right now I have a program containing a piece of code that looks
I have a program that is running inside eclipse right now and uses a
I have a program that opens a lot of folders right now, and I
I'm working on a C# program, and right now I have one Form and
Right now I have an SSIS package that runs every morning and gives me
Right now I have a JSP page that allows to sort some items, when
Right now I have a table called Campaigns that has many Hits, if I
I have a project right now that straddles the line on framework and pluggable
i have made a program in C using the gcc compiler. Right now it
Right now I have java program whose classes are currently POJOs and stored in

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.