Name
IsMultiThread Variable
Syntax
var IsMultiThread: Boolean;
Description
Delphi automatically sets
IsMultiThread
to True when you create a thread using
BeginThread
or with the TThread
class in the Classes
unit. You can test
IsMultiThread
and avoid some thread-protection
overhead when it is False.
Tips and Tricks
Delphi’s memory manager checks
IsMultiThread
and uses critical sections to protect the integrity of its internal data structures. Therefore, if you create a thread by calling the Windows API functionCreateThread
, you must explicitly setIsMultiThread
to True.Delphi also sets
IsMultiThread
to True for web servers and COM servers that don’t force single threading (tmSingle
threading model).If you write your own DLL that might be loaded by a multithreaded application, set
IsMultiThread
to True. If you useDllProc
to learn when more than one thread attaches to the DLL, you must realize the application might start multiple threads before loading the DLL.
See Also
BeginThread Function, DllProc Variable, ThreadVar Keyword |
Get Delphi in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.