Delphi threads deadlock

后端 未结 5 754
野性不改
野性不改 2020-12-23 18:10

I am having a problem sometimes with a deadlock when destroying some threads. I\'ve tried to debug the problem but the deadlock never seems to exist when debugging in the ID

5条回答
  •  庸人自扰
    2020-12-23 18:48

    Delphi's TThread object (and inheriting classes) already calls WaitFor when destroying, but it depends on whether you created the thread with CreateSuspended or not. If you are using CreateSuspended=true to perform extra initialization before calling the first Resume, you should consider creating your own constructor (calling inherited Create(false);) that performs the extra initialization.

提交回复
热议问题