add double checking lock for singleton and perthread behavior