Use CRITICAL_SECTION and CONDITION_VARIABLE. This requires Windows Vista or newer. It fixes problems with GLib threading objects that were implicitly created by static constructors before g_thread_init().