synchronize 是同步过程的
synchronize(a);
synchronize(b);
k可以有多个
2。
线程1执行synchronize(a); 其他线程只是不能运行 a而已
3
可以,肯定是你的程序有其他问题
synchronize(a);
synchronize(b);
k可以有多个
2。
线程1执行synchronize(a); 其他线程只是不能运行 a而已
3
可以,肯定是你的程序有其他问题
Thehe : heheThread类似的说明,所以,我要用一个按钮来中断线程,就不能用
Thehe.Terminate方法了,这个时候我该怎么来中断线程呢?两位真有大虾风范!我穷的只剩下分了!呵呵。
unit Unit2;interfaceuses
Classes,adodb,stdctrls;type
hehe = class(TThread)
Flistbox : Tlistbox;
Fadoquery : Tadoquery;
private
{ Private declarations }
protected
procedure Execute; override;
public
constructor Create(listbox : Tlistbox;q : Tadoquery);
end;implementationconstructor hehe.Create(listbox : Tlistbox;q : Tadoquery);
begin
Flistbox := listbox;
Fadoquery:= q; FreeOnTerminate := true; inherited Create(false);
end;procedure hehe.Execute;
begin
//Fadoquery.connectionstring := 'Provider=MSDASQL.1;Persist Security Info=False;Data Source=tian';
Fadoquery.close;
Fadoquery.sql.clear;
Fadoquery.sql.add('select top 10 * from Cata order by Tr');
Fadoquery.open; while not Fadoquery.eof do
begin
Flistbox.additem(Fadoquery.fieldbyname('Tr').asstring,self);
Fadoquery.next;
end;
end;end.unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, DB, ADODB;type
TForm1 = class(TForm)
Button1: TButton;
ListBox1: TListBox;
ListBox2: TListBox;
ADOQuery1: TADOQuery;
procedure Button1Click(Sender: TObject);
private
procedure threadDone(Sender : Tobject);
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementationuses unit2;{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
begin
with hehe.create(Listbox1,adoquery1) do
Onterminate := ThreadDone;
end;procedure Tform1.threadDone(Sender : Tobject);
begin
end;
end.
2、SYNCHRONIZE()使线程方法在主线程中执行,其它线程等待。
3、可以。