Global Exception Handlers in Java

后端 未结 2 1704
梦谈多话
梦谈多话 2021-02-09 07:04

I am thinking of setting up a global, default Exception handler for my (Android) Mobile application(which uses Java syntax) using Thread.setDefaultUncaughtExceptionHandler

2条回答
  •  清酒与你
    2021-02-09 07:37

    • The name is a bit misleading, because using that method will set a default exception handler for all threads.
    • Make sure no exceptions can be thrown from your exception handler.
    • If you're doing GUI stuff from your exception handler, make sure you're doing it from the right thread.
    • An uncaught exception will only stop the thread where the exception took place, if that also causes the process to terminate depends on any other threads that might be running.

提交回复
热议问题