Essentially the same as test4, but using pthread constructs instead of Boost.