这个不好说,要看数据交叉情况 有一种这样的 线程 while not Terminated do begin if not GetData(...) then Break;//从数据列表中获取计算行 ComputeIt(...);//计算数据 end;function GetData begin Lock(); if index<=High(...) then begin ... Result := True; end; UnLock(); end; 这种适合有主线的计算任务.CPU有几核或者支持几个线程就开几个线程.
有一种这样的
线程
while not Terminated do begin
if not GetData(...) then Break;//从数据列表中获取计算行
ComputeIt(...);//计算数据
end;function GetData
begin
Lock();
if index<=High(...) then begin
...
Result := True;
end;
UnLock();
end;
这种适合有主线的计算任务.CPU有几核或者支持几个线程就开几个线程.