Multithreading problem ?!! Master

Source: Internet
Author: User
Multithreading problem ?!! Experts come to Delphi/Windows SDK/API
Http://www.delphi2007.net/DelphiAPI/html/delphi_20061110202423255.html
A function
Funtion temp (AA: integer; BB: integer): string;
VaR
I, J: integer;
Begin
For I = 0 to AA do
Begin
For J = 0 to BB do
Begin
String: = string + string;
End;
End;
Result: = string;
End;
Both buttons call this function, that is, the input parameters are different. The first button is Temp (), and the second button is Temp)

How can I use multiple threads to separate calls? The wine can be clicked consecutively without two buttons, and it does not need to be processed before it can continue to be clicked;
The returned variables are also available !!!!!

> How to separate multiple threads,

You inherit two thread classes from thread and call temp in execute of the class,

For more information, seeCodeAh

I met another unmotivated lazy person.

Tmythread = Class (tthread)
Private
Fa: integer;
FB: integer;
Function temp (AA: integer; BB: integer): string;
Protected
Procedure execute; override;
Public
Constructor create (const AA, AB: integer); reintroduce;
End;


Constructor tmythread. Create (const AA, AB: integer; AE: tedit );
Begin
Freeonterminate: = true;
Inherited create (true );
Fa: = AA;
FB: = AB;
End;

Procedure tmythread. Execute;
Begin
Inherited;
Temp (FA, FB );
End;

..........
Procedure tform1.button1click (Sender: tobject );
Begin
With tmythread. Create (100,100) Do
Resume;
End;


Procedure tform1.button1click (Sender: tobject );
Begin
With tmythread. Create (1000,100 0) Do
Resume;
End;

This is just a basic framework. As for the actual project and synchronization display, there is still a lot of work to do. Learn it by yourself!

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.