Keep track of tasks submitted to ThreadPoolExecutor Keep track of tasks submitted to ThreadPoolExecutor multithreading multithreading

Keep track of tasks submitted to ThreadPoolExecutor


Why not simply keep a list of your Runnables?

List<Runnable> runnables = new ArrayList<> ();VideoExportThread r = new VideoExportThread(gcmPath);runnables.add(r);executor.submit(r);

Also note that executor.submit(r); returns a Future - you can call its isDone() method to check if the submitted task is still running.


Side comment: there might be a good reason to manage the job queue manually, but if not, you use one of the factory methods to make your life easier. For example: ExecutorService executor = Executors.newCachedThreadPool();.