fixed the thread explosion
Merge pull request #29 from neradis/issues/22

fixed the thread explosion