Add thread support for FreeBSD