如何创建一个线程安全的全局TList?Delphi:如何创建一个线程安全的全局TList?
unit Unit1;
interface
uses
...;
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
end;
var
Form1: TForm1;
global_TList: TList; // Not thread safe?
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
// something
end;
end.
我有两个线程,可以写入global_TList,但据我所知,它不是线程安全的。
那么如何让它安全?
德尔福2010年,印第安纳波利斯10,Win7的
相关:http://stackoverflow.com/questions/302583/how-can-i-implement-a-thread-safe-list-wrapper-in-delphi –
请参阅[Delphi帮助](http:// docwiki .embarcadero.com/CodeExamples/XE2/en/TThreadList_(Delphi))举例说明如何使用TThreadList。 –