1. 管理基本线程的生命期
生命期 :New -> Runnable -> Blocked/Waiting(Thread.sleep() | Thread.yield()) -> Terminated
Uncaught Exceptions
- Thread global handler:static void setDefaultUncaughtExceptionHandler(Thread.UncaughtExceptionHandler handler);
- Thread local handler:void setUncaughtExceptionHandler(Thread.UncaughtExceptionHandler handler);
- Unhandled Exceptions on the UI Thread,参见面试题记录(一)
|
|
在 Activity 中保持线程
- public Object onRetainNonConfigurationInstance():Called by the platform before a configuration change occurs, the implementation should return any object that you want to be retained across a configuration change (e.g., a thread) and passed to the new Activity object.
- public Object getLastNonConfigurationInstance():Called by the platform before a configuration change occurs, it can be called in onCreate or onStart and returns null if the Activity is started for another reason than a configuration change.

