[Lazarus] Synchronize troubles (attach forgotten, sorry)

JoshyFun joshyfun at gmail.com
Thu Feb 21 23:37:16 CET 2008


Hello Micha,

Thursday, February 21, 2008, 9:42:24 PM, you wrote:

>> I'm working in a program that needs multiple threads and one will
>> synchronize with main thread to display a log. I do not wish to
>> continue the caller thread meanwhile the Synchronize has not been
MN> Synchronize is blocking by itself already.

Yes... I had seen it also :)

>> multithread example code keeping only the things that I need, and to
>> ask to you if this is a Synchronize bug/problem or a non-wanted

MN> You've just illustrated a perfect example of a deadlock ;-).

Yes sure :) The problem is that it can not be solved in the same way,
so some code must be added (by my side) to prevent the call to the
affected thread when the current thread is the same as the main
thread, I'm thinking in a derived TThread class that handle the whole
block inside the tipical "while not terminated do" in a method and
nother function decide if the data must be handled by the new thread
or by the current thread (if it is the main one), for sure I must
elaborate a bit more.

MN> Synchronize blocks until SetString completes, but that doesn't complete
MN> until m_EventDone is set, but that only happens when Synchronize
MN> completes, which it never does.

Yes, I saw it (after 3-4 hours) after thinking how the message queue
is being handled and how is locking my code. I spend near one day to
find it :( Sometimes is better to take a coke and return a few hours
later.

Thank you for your help.

-- 
Best regards,
 JoshyFun




More information about the Lazarus mailing list