On windows, use CRITICAL_SECTION