[vlc-devel] [PATCH]Win32 screensaver disable change part II

Rémi Denis-Courmont remi at remlab.net
Tue May 3 09:44:27 CEST 2011


On Tuesday 03 May 2011, Kaarlo Räihä wrote:
> Problem with join is that 50 seconds long sleep function I have since AFAIK
> join needs selfterminating threads. But in Win32 (according to MSDN) you
> are allowed to use ExitThread or similar function to terminate threads
> since VLC is C code.

I believe ExitThread() would leak CRT resources. _endthread() or 
_endthreadex() must be used instead. Either way, you need to ensure that the 
thread exits "early enough", that is to say before any of the resources it 
uses are freed. There are only two ways to achieve that:
- join the thread before the resources are freed,
- keep all resources around and have the thread free them before it exits.

On Windows, FreeLibraryAndExitThread() is the only way to achieve the latter, 
that I know. As there is no _endthread() equivalent thereto, you cannot use 
it. So basically, you have to join the thread no matter what.

Rémi Denis-Courmont

More information about the vlc-devel mailing list