Refresh lock was used incorrectly

This commit is contained in:
daniel oeh 2013-08-05 15:01:31 +02:00
parent 75b13431fe
commit a90c7219f3
1 changed files with 4 additions and 4 deletions

View File

@ -10,6 +10,7 @@ import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.locks.ReentrantLock;
import android.content.Context;
@ -73,11 +74,10 @@ public final class DBTasks {
}
}
private static ReentrantLock refreshAllFeedsLock = new ReentrantLock();
private static AtomicBoolean isRefreshing = new AtomicBoolean(false);
public static void refreshAllFeeds(final Context context,
final List<Feed> feeds) {
if (refreshAllFeedsLock.tryLock()) {
if (isRefreshing.compareAndSet(false, true)) {
new Thread() {
public void run() {
if (feeds != null) {
@ -85,7 +85,7 @@ public final class DBTasks {
} else {
refreshFeeds(context, DBReader.getFeedList(context));
}
refreshAllFeedsLock.unlock();
isRefreshing.set(false);
}
}.start();
} else {