Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ MT-multithreading and servers » Wait for other Threads
Re: Wait for other Threads [message #46579 is a reply to message #46573] Fri, 03 June 2016 08:50 Go to previous messageGo to previous message
koldo is currently offline  koldo
Messages: 3437
Registered: August 2008
Senior Veteran
Hello funky

I am not an expert in multi threading and in my projects I use another focus. However I see two things in your code:

- I would replace while(Thread::GetCount()); with:
while(Thread::GetCount()) {
	ProcessEvents();
	Sleep(0);
}

I think that with while(Thread::GetCount()); you are locking main thread with an infinite loop, and Guilocks in threads will wait forever.
Calling ProcessEvents(); inside the loop you let the GUI to be refreshed by the threads you have launched.

- intfile
This is a variable handled globally by different threads without any control, so results will be undefined...
A safer way could be to declare intfile as Atomic and increase it with AtomicInc:
Atomic intfile;
...
AtomicInc(intfile);
intfile will behave as an int, but multiple threads will access it safely.


Best regards
IƱaki

[Updated on: Fri, 03 June 2016 08:51]

Report message to a moderator

 
Read Message icon5.gif
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: how to use the TcpSocket::Get?
Next Topic: skylark meet strange problem
Goto Forum:
  


Current Time: Fri Jun 27 17:17:15 CEST 2025

Total time taken to generate the page: 0.03488 seconds