added threads API

Hey Oscar, apologies no tests for this one. I am going to fully revise my rather over enthusiastic approach to the testing. It is not sustainable in the long run. So I now agree we should just try and get as comprehensive a sweet of integration tests possible.