Fix probable thread safety issue
Merge pull request #4 from ryansroberts/threadfun

Fix probable thread safety issue, thanks Ryan!