F
fortun
Unregistered / Unconfirmed
GUEST, unregistred user!
我创建了两个线程mythread1,mythread2,其程序框架如下:
unit Unit2;
interface
uses
Classes,Windows, Messages, SysUtils, Graphics, Controls, Forms, Dialogs,DB;
type
MyThread = class(TThread)
private
{ Private declarations }
protected
procedure Execute;
override;
procedure MyPro1;
end;
implementation
procedure MyPro1;
begin
.....
end;
procedure MyThread.Execute;
begin
{ Place thread code here }
MyPro1;
end;
end.
以下是mythread2单元
unit Unit3;
interface
uses
Classes,Windows, Messages, SysUtils, Graphics, Controls, Forms, Dialogs,DB;
type
MyThread = class(TThread)
private
{ Private declarations }
protected
procedure Execute;
override;
procedure MyPro2;
end;
implementation
procedure MyPro2;
begin
.....
end;
procedure MyThread.Execute;
begin
{ Place thread code here }
MyPro2;
end;
end.
MyPro1由远程服务器获取数据后写入本地数据库
MyPro2是对本地数据库进行操作。由于MyPro1和MyPro2都要对本地数据库进行操作
所以会引起访问冲突的问题。
请教各位如何避免访问数据库冲突啊。我刚开始使用线程,可以说是摸着石头过河。
最好说的详细一点。分数不够可以再加。
谢谢了[]
unit Unit2;
interface
uses
Classes,Windows, Messages, SysUtils, Graphics, Controls, Forms, Dialogs,DB;
type
MyThread = class(TThread)
private
{ Private declarations }
protected
procedure Execute;
override;
procedure MyPro1;
end;
implementation
procedure MyPro1;
begin
.....
end;
procedure MyThread.Execute;
begin
{ Place thread code here }
MyPro1;
end;
end.
以下是mythread2单元
unit Unit3;
interface
uses
Classes,Windows, Messages, SysUtils, Graphics, Controls, Forms, Dialogs,DB;
type
MyThread = class(TThread)
private
{ Private declarations }
protected
procedure Execute;
override;
procedure MyPro2;
end;
implementation
procedure MyPro2;
begin
.....
end;
procedure MyThread.Execute;
begin
{ Place thread code here }
MyPro2;
end;
end.
MyPro1由远程服务器获取数据后写入本地数据库
MyPro2是对本地数据库进行操作。由于MyPro1和MyPro2都要对本地数据库进行操作
所以会引起访问冲突的问题。
请教各位如何避免访问数据库冲突啊。我刚开始使用线程,可以说是摸着石头过河。
最好说的详细一点。分数不够可以再加。
谢谢了[]