Thread.WaitFor hangs the program if the thread has been freed already
Original Reporter info from Mantis: cordylus
-
Reporter name:
Original Reporter info from Mantis: cordylus
- Reporter name:
Description:
If FreeOnTerminate is enabled, the following pattern may work one time and hang the other, depending on whether the thread has terminated instantly or not:
AThread.Terminate;
AThread.WaitFor;
That might be wrong use, but the hang makes it hard to debug. Should be some error instead. Delphi (I checked 7 and 2000) gives an error.
Steps to reproduce:
An example with random reproducibility is attached, a dozen of clicks may be required to reproduce. Comment out all TMyThread.Execute function body to make it reproduce every time.
Mantis conversion info:
- Mantis ID: 34530
- Version: 3.0.4
- Fixed in version: 3.3.1
- Fixed in revision: 1538 (#2d4a93a3)
- Target version: 3.2.0