[Android] Prevent race conditions

Geoffrey Métais git at videolan.org
Mon May 22 15:29:49 CEST 2017


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon May 22 09:30:55 2017 +0200| [06d1140054e3bba5c9516c99108ea0572835bfe8] | committer: Geoffrey Métais

Prevent race conditions

> https://code.videolan.org/videolan/vlc-android/commit/06d1140054e3bba5c9516c99108ea0572835bfe8
---

 vlc-android/src/org/videolan/vlc/MediaParsingService.java | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/vlc-android/src/org/videolan/vlc/MediaParsingService.java b/vlc-android/src/org/videolan/vlc/MediaParsingService.java
index b2033b1..2a8e18c 100644
--- a/vlc-android/src/org/videolan/vlc/MediaParsingService.java
+++ b/vlc-android/src/org/videolan/vlc/MediaParsingService.java
@@ -65,6 +65,8 @@ public class MediaParsingService extends Service implements DevicesDiscoveryCb {
 
     private final ThreadPoolExecutor mThreadPool = new ThreadPoolExecutor(1, 1, 30, TimeUnit.SECONDS,
             new LinkedBlockingQueue<Runnable>(), VLCApplication.THREAD_FACTORY);
+    private final ThreadPoolExecutor mNotificationThreadPool = new ThreadPoolExecutor(1, 1, 2, TimeUnit.SECONDS,
+            new LinkedBlockingQueue<Runnable>(), VLCApplication.THREAD_FACTORY);
 
     boolean mScanPaused = false;
     private BroadcastReceiver mReceiver = new BroadcastReceiver() {
@@ -249,7 +251,7 @@ public class MediaParsingService extends Service implements DevicesDiscoveryCb {
                 return;
             mLastNotificationTime = currentTime;
         }
-        VLCApplication.runBackground(new Runnable() {
+        mNotificationThreadPool.execute(new Runnable() {
             @Override
             public void run() {
                 sb.setLength(0);



More information about the Android mailing list