public synchronized void cancelThreadDecoding(Thread thread, ContentResolver contentResolver) { ThreadStatus threadStatus = getOrCreateThreadStatus(thread); threadStatus.mState = State.CANCEL; if (threadStatus.mOptions != null) { threadStatus.mOptions.requestCancelDecode(); } notifyAll(); try { synchronized (threadStatus) { while (threadStatus.mThumbRequesting) { MediaStore.Images.Thumbnails.cancelThumbnailRequest(contentResolver, -1, thread.getId()); MediaStore.Video.Thumbnails.cancelThumbnailRequest(contentResolver, -1, thread.getId()); threadStatus.wait(200); } } } catch (Exception exception) { } }