IsMultiThread Variable
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.
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 function CreateThread
, you must
explicitly set IsMultiThread
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 use
DllProc
to learn when more than one thread
attaches to the DLL, you must realize the application might start
multiple threads before loading the
DLL.