[Android] Ensure lock is released

Geoffrey Métais git at videolan.org
Mon Feb 16 16:12:36 CET 2015


vlc-ports/android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Feb 16 15:07:49 2015 +0100| [25f9812f73cb928e49c0060c5035418c33e6ee41] | committer: Geoffrey Métais

Ensure lock is released

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=25f9812f73cb928e49c0060c5035418c33e6ee41
---

 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 a4952d1..a107400 100644
--- a/vlc-android/src/org/videolan/vlc/Thumbnailer.java
+++ b/vlc-android/src/org/videolan/vlc/Thumbnailer.java
@@ -96,9 +96,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();
+        }
     }
 
     /**
@@ -117,10 +120,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