place lock call inside try block