Use thread local variables when it may be changed from parent thread
Merge pull request #38 from ToQoz/use_thread_local_variables

Use thread local variables when it may be changed from parent thread