Board index » cppbuilder » Dead lock in Component with threads
Dead lock in Component with threads
2003-08-15 06:59:49 AM
I have the following problem with multithreading:
My component creates one or more threads that do some work and now and then
update the user interface (main form in VCL main thread) via Synchronize().
Until now I thought I would be save with Synchronize() but sometimes I seem
to have dead locks when closing the program while the threads are still
My first thought was that the main form is already destroying and the
threads of my component still try to synchronize. Since Synchronize() is
blocking the threads wait for the main thread to process messages. The main
thread, however, is already out of its message loop and is waiting for the
threads to terminate. Can anyone confirm that this could be?
Now I let my threads check the components csDestroying flag before trying to
synchronize and it seems to help. But is this save enough?
Any other ideas how to avoid this conflict when closing a program with
active worker threads?
thanks for any idea,