Forum > Unix

[SOLVED] TThread.WaitFor locks forever

(1/2) > >>

Gustavo 'Gus' Carreno:
Hey Y'all,

NOTE: Putting this here since I was only able to test this on Linux(Ubuntu 23.04 64b).

I'm exploring all the possibilities of threads since I have a project that will heavily rely on them.
In order to do that I've been following the Multithreaded Application Tutorial entry on the wiki.
One of the See Also links mentioned is the Manager Worker Threads System.
I downloaded the archived files from Source Forge: Manager Worker Thread Example.

Attached is the same example with some alterations:

* Added an event to log stuff on the main forms ( Not using it since I needed to use WriteLn to debug the Destroy parts )
* Corrected a small bug that would only add one worker thread to the pool.
Now, here's the problem:
  When the application ends, it tries to Terminate->WaitFor->FreeAndNil each of the created worker threads.
  That's expected and it should be ok for all the created threads!! ( In the example I use a queue of 3 )

But in my Linux environment, it will do that for Worker 0, but then it will get stuck on the WaitFor of Worker 1 forever.
Since all 3 workers are created equal and they don't differ in anything obvious that I can see, I'm completely baffled and in need of help from the community!!

Many thanks in advance!!

Cheers,
Gus

440bx:
Just out of curiosity... is the code supposed to work on Windows ? and if it is then have you tried the code in Windows ?  if yes, does the problem show up there too ?


Gustavo 'Gus' Carreno:
Hey 440bx,


--- Quote from: 440bx on September 04, 2023, 04:20:15 am ---Just out of curiosity... is the code supposed to work on Windows ?

--- End quote ---

I think, but I'm not quite sure, that the original coder did work in Windows, so I'm kinda assuming a YES here.


--- Quote from: 440bx on September 04, 2023, 04:20:15 am ---and if it is then have you tried the code in Windows ? 

--- End quote ---

The only way I can test under Windows is with wine.
All my attempts doing so have resulted in the app claiming the error depicted on the attached image.
I've done what I know to remove any files being loaded at start, but I've failed.


--- Quote from: 440bx on September 04, 2023, 04:20:15 am ---if yes, does the problem show up there too ?

--- End quote ---

As you can see by the above error in wine, I haven't been able to even get to the Close App part of the test :(

Cheers,
Gus

sikale@aliyun.com:
Unable to close in windows OS

paweld:
Remove SetSize(0) from CriticalSection (in procedureTManagerThread.Clear) because "GetNextItem" already blocks CS. 
And why so many critical sections? 
   
Tested on Windows 10 and Debian 11

Navigation

[0] Message Index

[#] Next page

Go to full version