CropImage中为什么使用CountDownLatch难道不阻塞UI线程吗?
private void startFaceDetection() {--------------------编程问答-------------------- 调用CountDownLatch里面的方法的线程不是主线程吧?根据代码看都是在new的一个Runnable中调用的喎。
if (isFinishing()) {
return;
}
mImageView.setImageBitmapResetBase(mBitmap, true);
Util.startBackgroundJob(this, null, getResources().getString(Res.string.running_face_detection), new Runnable() {
public void run() {
final CountDownLatch latch = new CountDownLatch(1);
final Bitmap b = mBitmap;
mHandler.post(new Runnable() {
public void run() {
if (b != mBitmap && b != null) {
mImageView.setImageBitmapResetBase(b, true);
mBitmap.recycle();
mBitmap = b;
}
if (mImageView.getScale() == 1.0f) {
mImageView.center(true, true);
}
latch.countDown();
}
});
try {
latch.await();
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
mRunFaceDetection.run();
}
}, mHandler);
}
不过不确定,有牛人详细说明么?哈!
补充:移动开发 , Android