Code: Alles auswählen
type
TOperation=class
procedure Run;
end;
TMyThread=class(TThread)
constructor Create(aOp:Toperation)
end;
for i:=0 to OperationList.Count-1 do
TMyThread.Create(TOperation(OperationList[i]));
constructor TMyThread.Create(aOp:TOperation);
begin
inherited Create(true);
FOp:=aOp;
Start;
end;
procedure TMyThread.Execute;
begin
FOp.Run;
end;
Das klappt unter Linux und Windows ganz gut, aber Darwin hat zu 100% nach kurzer Zeit EXC_BAD_ACCESS ausgeworfen. Ich habe rumprobiert und dabei die Parameterübergabe geändert.
Code: Alles auswählen
TMyThread=class(TThread)
constructor Create;
property Operation:TOperation read write;
end;
for i:=0 to OperationList.Count-1 do
begin
aThread:=TMyThread.Create;
aThread.Operation:=TOperation(OperationList[i]);
aThread.Start;
end;
Damit läuft die Routine plötzlich problemlos. Kann mir das jemand erklären?