Fix for threaded Perl

Thanks to rurban.
https://rt.cpan.org/Public/Bug/Display.html?id=94112