Discussion:
Question about Threads
(too old to reply)
Eduardo Jauch
2007-07-04 13:31:07 UTC
Permalink
Helo!

I have an app that creat one TThread to acsess internet.

Now, I want to use the Main Thread to access the internet and when some
conditions on the html page are satisfied, execute another thread (can
be more thna one now). These threads are all created with
FreeOnTerminate set to false.

My doubt is that one, some or all of the threads executeds, may don't
finish with an ok status, and than, they must return without terminate
to be executed again when the conditions on main thread are satisfied
again, until they finish with an ok status.


Can I do the EXECUTE method of the thread multiply times? How can I know
if the thread are running?

Any ideas on how I can do this?

If I must create these threads when I need then, this is do fast?

Thanks!
Clayton Arends
2007-07-04 16:59:14 UTC
Permalink
Post by Eduardo Jauch
Can I do the EXECUTE method of the thread multiply times?
Depending on how you design your threads they can be used multiple times or
just once. However, once the Execute() method is exited the thread can no
longer be used.
Post by Eduardo Jauch
How can I know if the thread are running?
If your main thread hooks into the "OnTerminate" event then you will know
when the thread has finished its work and perform other tasks at that point.
Post by Eduardo Jauch
If I must create these threads when I need then, this is do fast?
The time it takes to create a thread shouldn't really be a concern unless
you would be creating dozens of threads per second. I would suggest
designing your thread to terminate on success and failure. You can set an
internal status flag or error code and let the main thread decide if another
thread should be created and the work should be attempted again.

- Clayton

Loading...