Newsgroups : Borland : borland.public.delphi.internet.winsock : 2006 Mar : Re: TIdTCPServer - threads, global data
| Subject: | Re: TIdTCPServer - threads, global data |
| Posted by: | "Mathijs" (blab..@bla.hu) |
| Date: | 16 Mar 2006 08:27:44 |
16 mrt 2006, (Remy Lebeau (TeamB)):
> "Mathijs" <blabla@bla.hu> wrote in message
> news:Xns978864922B9BBholleknolle23@207.105.83.66...
>
>> When a client sends the command to retrieve the open tables or
>> register for a table, I need to access a global TList of tables, for
>> example.
>
> You do not need to delegate that work to the main thread at all. Use
> a TThreadList instead of a TList. TThreadList wraps a TList with a
> critical section. That way, your connection threads can access the
> global data directly, in a thread-safe manner, without making the main
> thread do all of the work on behalf of the threads.
>
Thanks. This is new for me. Can I use(read/write) the objects stored in
the TThreadList no matter what kind of object it is?
And what if I want to use a TStringList? Or a TWhatEver? Put it in a
TThreadList (threadlist.add(AWhatEver);) and use it from there
(TWhatEver(threadlist.items[0]).DoSomething)? Or is it better to make
TWhatever thread safe from scratch (with a critical section)?
Cheers,
M.