[Android] Ensure lock is released
Geoffrey Métais
git at videolan.org
Mon Feb 16 16:15:39 CET 2015
vlc-ports/android | branch: 1.0.x | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Feb 16 15:07:49 2015 +0100| [40ee26bc773ced16547f326a24058ccdf1dcf630] | committer: Geoffrey Métais
Ensure lock is released
(cherry picked from commit 25f9812f73cb928e49c0060c5035418c33e6ee41)
> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=40ee26bc773ced16547f326a24058ccdf1dcf630
---
vlc-android/src/org/videolan/vlc/Thumbnailer.java | 20 +++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/Thumbnailer.java b/vlc-android/src/org/videolan/vlc/Thumbnailer.java
index 90c789d..706b9cd 100644
--- a/vlc-android/src/org/videolan/vlc/Thumbnailer.java
+++ b/vlc-android/src/org/videolan/vlc/Thumbnailer.java
@@ -98,9 +98,12 @@ public class Thumbnailer implements Runnable {
*/
public void clearJobs() {
lock.lock();
- mItems.clear();
- totalCount = 0;
- lock.unlock();
+ try {
+ mItems.clear();
+ totalCount = 0;
+ } finally {
+ lock.unlock();
+ }
}
/**
@@ -111,10 +114,13 @@ public class Thumbnailer implements Runnable {
if(BitmapUtil.getPictureFromCache(item) != null || item.isPictureParsed())
return;
lock.lock();
- mItems.add(item);
- totalCount++;
- notEmpty.signal();
- lock.unlock();
+ try {
+ mItems.add(item);
+ totalCount++;
+ notEmpty.signal();
+ } finally {
+ lock.unlock();
+ }
Log.i(TAG, "Job added!");
}
More information about the Android
mailing list