added thread safety option

Merge thread safety please