Update HandlerThread.md

master
Omooo 5 years ago
parent eb62b075b7
commit c83269b9d2
  1. 2
      blogs/Android/HandlerThread.md

@ -103,6 +103,7 @@ public class HandlerThread extends Thread {
Looper.prepare(); Looper.prepare();
synchronized (this) { synchronized (this) {
mLooper = Looper.myLooper(); mLooper = Looper.myLooper();
// 通知取 Looper 的线程,此时 Looper 已经创建好了
notifyAll(); notifyAll();
} }
Process.setThreadPriority(mPriority); Process.setThreadPriority(mPriority);
@ -119,6 +120,7 @@ public class HandlerThread extends Thread {
synchronized (this) { synchronized (this) {
while (isAlive() && mLooper == null) { while (isAlive() && mLooper == null) {
try { try {
// 如果新线程还未创建 Looper,则等待
wait(); wait();
} catch (InterruptedException e) { } catch (InterruptedException e) {
} }

Loading…
Cancel
Save