|
|
@ -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) { |
|
|
|
} |
|
|
|
} |
|
|
|