[Lazarus] Multithreadprocs and Synchronize
Juha Manninen (gmail)
juha.manninen62 at gmail.com
Mon Aug 23 21:28:50 CEST 2010
On Monday 23 August 2010 21:14:11 Felipe Monteiro de Carvalho wrote:
> Synchronize should work for sure.
>
> I took a quick look and it is: 210 Object not initialized
>
> It's hard to say without seeing your code, but I guess there is a bug
> in your code somewhere.
>
> Another guess would be that this code is executed before the
> initialization of cthreads.
procedure TCombBlock.ShowStatus;
begin
;
end;
procedure TCombBlock.SolveSubBlocks(aThreadIndex: PtrInt; Data: Pointer; Item:
TMultiThreadProcItem);
begin
Item.Thread.Synchronize(Item.Thread, @ShowStatus); // <-- this gives error!
...
end;
function TCombBlock.SolveFirst: Boolean;
begin
...
fOwner.fThreadPool.DoParallel(@SolveSubBlocks,1,fFindInd-1,nil);
...
end;
-------------
I removed the other lines from the functions for this example.
Only "Item.Thread.Synchronize(..." gives the problem.
fOwner is a normal class derived from TObject.
I debugged to see the problem. It turned out "Item.Thread" is nil!
So the problem is actually that Multithreadprocs does not pass the underlying
thread object for a parallel function.
Juha
More information about the Lazarus
mailing list