Interrupting BitmapFactory.decodeStream
问题 Let's assume we have a worker thread which calls BitmapFactory.decodeStream with some connection stream, like this: Bitmap bitmap = BitmapFactory.decodeStream(new URL(imgUrl).openConnection().getInputStream(), null, someUnrelatedOptions); Now we need to terminate this thread immedietely in order to reclaim any memory that BitmapFactory has allocated. We can't wait for it to finish for too long, as the memory is required by UI thread. The example is simplified, so let's don't go into details