Starting and Stopping Threads

From RAD Studio
Jump to: navigation, search

Go Up to Executing thread objects Index

Proper thread synchronization techniques should be based on TEvent and TMutex.

Avoid using Suspend and Resume. Suspending and resuming a thread using these two functions can result in undefined behavior and in deadlock situations that are hard to debug and fix later on.

You can request that a thread end execution prematurely by calling the Terminate method. Terminate sets the thread's Terminated property to True. If you have implemented the Execute method properly, it checks the Terminated property periodically, and stops execution when Terminated is True.

See Also