aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2014-02-11 18:58:22 -0800
committerScott Jackson <daneren2005@gmail.com>2014-02-11 18:58:22 -0800
commit1503da8ce1e116332bd81abc25fa550da13a43cb (patch)
tree8ddf3fce74519bb98c6f81f36be5a577e2803903 /src
parent227c8d78bf3a31328a828ee128f0dbf0d206e90a (diff)
downloaddsub-1503da8ce1e116332bd81abc25fa550da13a43cb.tar.gz
dsub-1503da8ce1e116332bd81abc25fa550da13a43cb.tar.bz2
dsub-1503da8ce1e116332bd81abc25fa550da13a43cb.zip
Fix web commit
Diffstat (limited to 'src')
-rw-r--r--src/github/daneren2005/dsub/util/BackgroundTask.java15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/github/daneren2005/dsub/util/BackgroundTask.java b/src/github/daneren2005/dsub/util/BackgroundTask.java
index 4ff1f20a..4e71188f 100644
--- a/src/github/daneren2005/dsub/util/BackgroundTask.java
+++ b/src/github/daneren2005/dsub/util/BackgroundTask.java
@@ -20,6 +20,11 @@ package github.daneren2005.dsub.util;
import java.io.FileNotFoundException;
import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.LinkedBlockingQueue;
import org.xmlpull.v1.XmlPullParserException;
@@ -37,16 +42,16 @@ public abstract class BackgroundTask<T> implements ProgressListener {
private final Activity activity;
- private static final DEFAULT_CONCURRENCY = 5;
+ private static final int DEFAULT_CONCURRENCY = 5;
private static final Collection<Thread> threads = Collections.synchronizedCollection(new ArrayList<Thread>(DEFAULT_CONCURRENCY));
- private static final BlockingQueue<Task> queue = new BlockingQueue<Task>(10);
+ protected static final BlockingQueue<BackgroundTask.Task> queue = new LinkedBlockingQueue<BackgroundTask.Task>(10);
private static final Handler handler = new Handler();
public BackgroundTask(Activity activity) {
this.activity = activity;
if(threads.isEmpty()) {
- for(int i = 0; i < DEFAULT_CONCURRENY; i++) {
+ for(int i = 0; i < DEFAULT_CONCURRENCY; i++) {
Thread thread = new Thread(new TaskRunnable(), String.format("BackgroundTask_%d", i));
threads.add(thread);
thread.start();
@@ -132,7 +137,7 @@ public abstract class BackgroundTask<T> implements ProgressListener {
onDone(result);
}
});
- } catch(Throwable t) {
+ } catch(final Throwable t) {
if(isCancelled()) {
return;
}
@@ -158,7 +163,7 @@ public abstract class BackgroundTask<T> implements ProgressListener {
}
}
- private class TaskRunnable extends Runnable {
+ private class TaskRunnable implements Runnable {
private boolean running = true;
public TaskRunnable() {