how to handle exception in multi-thread