Delphi encapsulates a very powerful threading class TThread,
We also make a simple threading class by ourselves
First type of a class
[Delphi]View PlainCopy
- type
- twwthread = class
- constructor create; overload;
- DESTRUCTOR DESTROY; OVERRIDE;  
- PRIVATE  
- m_hthread: thandle; //thread
- m_threadid : tthreadid;
- public
- procedure execute;
- END;  
[Delphi]View PlainCopy
- function Wwthreadproc (thread:twwthread): Integer;
- Begin
- Thread. Execute (); //
- End
- Constructor Twwthread. Create;
- Begin
- M_hthread: = CreateThread (nil, 0, @wwThreadProc, Pointer (self), 0, M_threadid); {The focus here is on the fourth parameter, passing the class pointer as a parameter, so you can execute the method inside the class}
- End
- destructor Twwthread. Destroy;
- Begin
- inherited;
- End
- Procedure Twwthread. Execute;
- Begin
- //write the code here
- End
To declare:
[Delphi]View PlainCopy
- Var
- Mythread:twwthread;
Start ~
[Delphi]View PlainCopy
- MyThread: = Twwthread. Create;
http://blog.csdn.net/warrially/article/details/7887700
Delphi Thread Class DIY (pass the class pointer as a parameter, you can execute the method in the class)