threads support

Add protection from remove temporary files from other thread.