Fix thread synchronization bug
Merge pull request #27 from Livven/master

Fix thread synchronization bug