Skip to content

Commit

Permalink
automatically kill executorservices
Browse files Browse the repository at this point in the history
  • Loading branch information
axxapy committed Jun 2, 2017
1 parent 480228d commit 8b58968
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/axp/tool/apkextractor/ApkListAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,22 @@
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;

public class ApkListAdapter extends RecyclerView.Adapter<ApkListAdapter.ViewHolder> {
private ThreadFactory tFactory = new ThreadFactory() {
@Override
public Thread newThread(Runnable r) {
Thread t = new Thread(r);
t.setDaemon(true);
return t;
}
};

private ArrayList<ApplicationInfo> list = new ArrayList<ApplicationInfo>();
private ArrayList<ApplicationInfo> list_original = new ArrayList<ApplicationInfo>();
private ExecutorService executorServiceNames = Executors.newFixedThreadPool(3);
private ExecutorService executorServiceIcons = Executors.newFixedThreadPool(3);
private ExecutorService executorServiceNames = Executors.newFixedThreadPool(3, tFactory);
private ExecutorService executorServiceIcons = Executors.newFixedThreadPool(3, tFactory);
private Handler handler = new Handler();
public MainActivity mActivity;
public final PackageManager packageManager;
Expand Down Expand Up @@ -58,7 +68,10 @@ public void run() {
@Override
public void run() {
names_to_load--;
if (names_to_load == 0) mActivity.hideProgressBar();
if (names_to_load == 0) {
mActivity.hideProgressBar();
executorServiceNames.shutdown();
}
}
});
}
Expand Down

0 comments on commit 8b58968

Please sign in to comment.