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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T05:31:19+00:00 2026-06-15T05:31:19+00:00

I create a thread type ss_thread = class; ss_thread = class(TThread) protected Fff_id :

  • 0

I create a thread

type 
  ss_thread = class;

  ss_thread = class(TThread)
  protected
    Fff_id : string;
    Fff_cmd : string;
    Fff_host : string;
    Fff_port : TIdPort;
    procedure Execute; override;
  public
    constructor Create(const ff_id, ff_cmd: string; ff_host: string; ff_port: TIdPort);
  end;

constructor ss_thread.Create(const ff_id, ff_cmd: string; ff_host: string; ff_port: TIdPort);
begin
  inherited Create(False);
  Fff_id   := ff_id;
  Fff_cmd  := ff_cmd;
  Fff_host := ff_host;
  Fff_port := ff_port;
end;

...
id := 123; // dynamic
...

nst_ss_thread.Create(id, cmd, host, port);

and doing something on

procedure ss_thread.Execute;
var
  ws : TIdTCPClient;
  data : TIdBytes;
  i : integer;
  list : TList;
begin
      ws := TIdTCPClient.Create(nil);
      ws.Host := Fff_host;
      ws.Port := Fff_port;
....

I have master thread, which receive data from other source, and I need to forward all data to my threads with ID i received to ‘ws’ IdTCPClient.

How to have a list of IdTCPClients of all my created threads ?

Thanks

  • 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-06-15T05:31:21+00:00Added an answer on June 15, 2026 at 5:31 am

    Store them in a thread list.

    ClientList: TThreadList<TIdTCPClient>;
    

    Create one of these objects before you create any clients.

    ClientList := TThreadList<TIdTCPClient>.Create;
    

    Whenever you create a client, add it:

    procedure ss_thread.Execute;
    var
      List: TList<TIdTCPClient>;
    ....
    ws := TIdTCPClient.Create(nil);
    List := ClientList.LockList;
    try
      List.Add(ws);
    finally
      ClientList.UnlockList;
    end;
    

    Whenever you need to iterate over the clients, you can do so like this:

    var
      List: TList<TIdTCPClient>;
      Client: TIdTCPClient;
    ....
    List := ClientList.LockList;
    try
      for Client in List do
        // do something with Client
    finally
      ClientList.UnlockList;
    end;
    

    In the thread’s destructor you will also need to remove the client from the list.

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

Sidebar

Related Questions

I create a thread type ss_thread = class; ss_thread = class(TThread) protected Fff_id :
I would like to create a thread pool. I have a class called ServerThread.cpp,
I'm trying to create a thread class that executes a functor from an adapter.
It is possible to create various type of Thread Executors in Java, singleThreadedExecutor ,
I create a thread in my main class. The thread has a timer which
Odd even number printing using thread.Create one thread class, two instance of the thread.
In attempting to create a thread-safe container class from scratch, I've run into the
when i create a thread, i want to pass several arguments. So i define
I try to create a thread in QT, can declare, create and start it,
How do we create multiple thread during runtime in C programming language? If we

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.