S
sharknt
Unregistered / Unconfirmed
GUEST, unregistred user!
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
ListBox1: TListBox;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
procedure ThreadsDone(Sender:TObject);
public
{ Public declarations }
end;
TFooThread=class(TThread)
protected
procedure Execute;override;
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
const
MaxSize=128;
var
NextNumber:integer=0;
do
neFlags:integer=0;
GlobalArray:array[1..MaxSize]of integer;
function GetNextNumber:integer;
begin
Result:=NextNumber;
Inc(NextNumber);
end;
procedure TFooThread.execute;
var
I:integer;
begin
OnTerminate:=TForm1.ThreadsDone;
//问题就出在这,谁能帮助我
for I:=1 to MaxSizedo
begin
GlobalArray:=GetNextNumber;
Sleep(5);
end;
end;
procedure TForm1.ThreadsDone(Sender:Tobject);
var
I:integer;
begin
Inc(DoneFlags);
ifdo
neFlags=2 then
for i:=1 to MaxSizedo
Listbox1.items.add(IntToStr(GlobalArray));
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
TFooThread.Create(False);
TFooThread.Create(False);
end;
end.
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
ListBox1: TListBox;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
procedure ThreadsDone(Sender:TObject);
public
{ Public declarations }
end;
TFooThread=class(TThread)
protected
procedure Execute;override;
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
const
MaxSize=128;
var
NextNumber:integer=0;
do
neFlags:integer=0;
GlobalArray:array[1..MaxSize]of integer;
function GetNextNumber:integer;
begin
Result:=NextNumber;
Inc(NextNumber);
end;
procedure TFooThread.execute;
var
I:integer;
begin
OnTerminate:=TForm1.ThreadsDone;
//问题就出在这,谁能帮助我
for I:=1 to MaxSizedo
begin
GlobalArray:=GetNextNumber;
Sleep(5);
end;
end;
procedure TForm1.ThreadsDone(Sender:Tobject);
var
I:integer;
begin
Inc(DoneFlags);
ifdo
neFlags=2 then
for i:=1 to MaxSizedo
Listbox1.items.add(IntToStr(GlobalArray));
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
TFooThread.Create(False);
TFooThread.Create(False);
end;
end.