Bug fixes of the pthread specific and a test added.
Merge pull request #1525 from yukoba/pthread-specific

Bug fixes of pthread specific