How to create a Thread Safe global 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.
I have two threads, which can write to global_TList , but as I know, it's not thread safe.
So how to make it safe?
Delphi 2010, Indy 10, Win7
Use TThreadList. Problem solved.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With