to deal with thread resource error