addded cross-platform threading functions, will add to main code tomorrow