Delphi has a thread class tthread is used to achieve multithreaded programming, the vast majority of Delphi to have said, but basically is the TThread class of several members make a brief introduction, and then Explain the implementation of execute and the use of synchronize is over. This is not all of multithreaded programming, however, and I am writing this to supplement this.
Threads are essentially code that runs concurrently in a process. A process has at least one thread, that is, the so-called mainline thread. You can also have multiple child threads. When more than one thread is used in a process, it is called "multithreading."
So how does this so-called "piece of code" define it? is actually a function or process (for Delphi).
If you use the Windows API to create a thread, it is done through an API function called CreateThread, which is defined as:
HANDLE CreateThread(
LPSECURITY_ATTRIBUTES lpThreadAttributes,
DWORD dwStackSize,
LPTHREAD_START_ROUTINE lpStartAddress,
LPVOID lpParameter,
DWORD dwCreationFlags,
LPDWORD lpThreadId
);
Each of its parameters, as their name says, the following are: Thread attributes (for the security property setting of the thread under NT, invalid under 9X), stack size, start address, parameters, create flags (to set the state at which the thread was created), the thread ID, and finally the thread handle. The starting address is the entry of the thread function until the thread function ends and the thread ends.
The execution process for the entire thread is shown below: