Loading app/src/main/java/app/fedilab/android/mastodon/helper/NotificationsHelper.java +13 −1 Original line number Diff line number Diff line Loading @@ -65,7 +65,18 @@ public class NotificationsHelper { public static HashMap<String, List<String>> pushed_notifications = new HashMap<>(); public static ReentrantLock lock = new ReentrantLock(); private static final HashMap<String, ReentrantLock> lockMap = new HashMap<>(); private static ReentrantLock getLock(String slug) { synchronized (lockMap) { if (lockMap.containsKey(slug)) { return lockMap.get(slug); } ReentrantLock lock = new ReentrantLock(); lockMap.put(slug, lock); return lock; } } public static synchronized void task(Context context, String slug) throws DBException { Loading Loading @@ -94,6 +105,7 @@ public class NotificationsHelper { } new Thread(() -> { ReentrantLock lock = getLock(slug); try { // fetch if we get the lock, or ignore, another thread is doing the job if (lock.tryLock()) { Loading Loading
app/src/main/java/app/fedilab/android/mastodon/helper/NotificationsHelper.java +13 −1 Original line number Diff line number Diff line Loading @@ -65,7 +65,18 @@ public class NotificationsHelper { public static HashMap<String, List<String>> pushed_notifications = new HashMap<>(); public static ReentrantLock lock = new ReentrantLock(); private static final HashMap<String, ReentrantLock> lockMap = new HashMap<>(); private static ReentrantLock getLock(String slug) { synchronized (lockMap) { if (lockMap.containsKey(slug)) { return lockMap.get(slug); } ReentrantLock lock = new ReentrantLock(); lockMap.put(slug, lock); return lock; } } public static synchronized void task(Context context, String slug) throws DBException { Loading Loading @@ -94,6 +105,7 @@ public class NotificationsHelper { } new Thread(() -> { ReentrantLock lock = getLock(slug); try { // fetch if we get the lock, or ignore, another thread is doing the job if (lock.tryLock()) { Loading