Revert "Revert "Merge pull request #19 from budjb/threads""

This reverts commit 171cadeb0f0a6aa8f4928f874802486ecd220fc5.