Root > Advanced topics > Multi-threaded applications > Creating threads

Creating threads

Previous pageReturn to chapter overviewNext page   

There are the following possibilities to create threads in Delphi / C++ Builder applications:

CreateThread - a basic function to create any thread. This is a system function;
oBeginThread - a wrapper for CreateThread function. This is a RTL function;
TThread - a wrapper for BeginThread function;
Frameworks (AsyncCalls, OmniThreadLibrary, etc.) - wrappers for TThread class;
oThread pools (QueueUserWorkItem, etc.) - wrappers for CreateThread function;


Usually your code will use TThread or BeginThread as low-level thread creation routines. Or your code may use frameworks/thread pools. You should never use CreateThread function to create threads.


EurekaLog offers two extended routines which greatly simplify creating threads for debugging:

BeginThreadEx function - a wrapper for BeginThread function which adds support for naming thread and enabling EurekaLog. This function can be used in any application without enabling/including EurekaLog.
TThreadEx class - a wrapper for TThread class which adds support for naming thread and enabling EurekaLog. This class can be used in any application without enabling/including EurekaLog.


It is recommended to use BeginThreadEx function instead of BeginThread function and to use TThreadEx class instead of TThread class.


Important note: turning off low-level hooks means that EurekaLog will not install additional hooks for API functions. This means that EurekaLog will not intercept important system calls. For example, EurekaLog will not hook ExitThread function, which means EurekaLog will not know when a thread exits. This will lead to thread information stored forever - until application terminates. You can call internal _NotifyThreadGone or _CleanupFinishedThreads functions (from EThreadsManager unit) to notify EurekaLog about thread's termination. Such manual notifications can be avoided by using EurekaLog's wrappers (TThreadEx, for example).



See also:

Send feedback... Build date: 2018-11-26
Last edited: 2018-06-14
The documentation team uses the feedback submitted to improve the EurekaLog documentation. We do not use your e-mail address for any other purpose. We will remove your e-mail address from our system after the issue you are reporting has been resolved. While we are working to resolve this issue, we may send you an e-mail message to request more information about your feedback. After the issues have been addressed, we may send you an email message to let you know that your feedback has been addressed.

Permanent link to this article: