RAD Studio |  |

Writing the Thread Function
See Also
Collapse All

The Execute method is your thread function. You can think of it as a program that is launched by your application, except that it shares the same process space. Writing the thread function is a little trickier than writing a separate program because you must make sure that you don't overwrite memory that is used by other threads in your application. On the other hand, because the thread shares the same process space with other threads, you can use the shared memory to communicate between threads.

When implementing the Execute method, you can manage these issues by:

- Using thread-local variables
- Avoiding simultaneous access
- Waiting for other threads
- Checking for termination by other threads
- Handling exceptions in the thread function

See Also

Initializing the Thread

Writing Clean-up Code

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!