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

  • Home
  • SEARCH
  • 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 6797933
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:40:11+00:00 2026-05-26T18:40:11+00:00

So this is my question , threads are so confusing for me , let’s

  • 0

So this is my question , threads are so confusing for me , let’s say I have 5 threads , and 50 or 100 or more sites. So as far as I’ve learned about threads , I can make constructor create (link:string) and start new threads with different links , but than I wold need to make as much threads as the number of links I need to parse.So how can I make variable link shared between threads , so when thread one downloads link listbox1.items[0] it tells others that number 0 is downloaded and next thread should ask what link should I download and get answer listbox1.items[1] and so on until they download all links when they should terminate.
Can anyone provide me with simple example of how can this be done. Threads are killing me 🙁

  • 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-26T18:40:11+00:00Added an answer on May 26, 2026 at 6:40 pm

    Sounds like you simply need to set up a critical section.

    This needs to be set up around the code segment which reads the next URL. To do this you would typically place a semaphore at the start of the code so that only one thread can enter it at any time. The semaphore is reset at the end of the code. As each new thread sees the URL list has expired, then it terminates.

    Typically semaphores are boolean, but they can be integers for example if you want to allow a specific number of threads to enter the region at any time.

    In your case you can simply set up a global boolean variable (visible to all threads), say “fSemaphore”.

    At the start of the region, the thread checks the flag. If it is false it sets it to true and enters the region (to get the next URL).
    If it is true, then it loops – e.g. repeat sleep(0) until (not fSemaphore).
    When it exits the region it set fSemaphore := False;

    Obviously you need to make sure you guard against a possible infinite loop scenario…

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

Sidebar

Related Questions

This question is about using getter methods of a singleton object in worker threads.
In this question , I asked about using queue's and threads in C#. I
I am re-hashing this question because I have looked at over 50 threads in
This question isn't about the technical usage of restricted, more about the subjective usage.
This is a very serious question: I've seen lots of threads here about gravatars
There are already several threads where this question is discussed, and I have already
This is kind of a follow-up question to this . When I'm debugging threads
This question is based on the thread . I have the shell function function
This thread got too confusing (for me) so I am asking the question again.
This question is not about, whether spurious wakeups actually happen, because this was already

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.