The Thread Class in Delphi (1)

Source: Internet
Author: User

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:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.