avoid segment fault (because of using non-const global variable in multi-threads)