thread-safe impl
Merge pull request #13 from maxless/master

Thread safety implementation