How to use the BackgroundWorker

Im trying to create several background tasks and load them into the
BackgroundTaskHandler backgroundTaskHandler = backgroundWorker.handle(task1);
backgroundTaskHandler.execute();

the execute will run all of them parallel right? what if i have 400 tasks and i want them to run in parallel in 4 or 8 simultaneously?

thanks in advance !!

Does this even make sense?

List<BackgroundTaskHandler> handlers = new ArrayList<>();
for (Map.Entry<Integer, List<SomeObject>> entry : someMap.entrySet()) {
	BackgroundTask<Integer, Void> task = new DemoTask(entry.getValue());
    handlers.add(backgroundWorker.handle(task));
}

handlers.forEach(h->h.execute());

will this run parallel?

How can I know all the tasks are completed?

Finally how can I run this from a service bean and update the UI progress from there.

You can use ExecutorService inside a BackgroundTask to handle your 400 tasks in multiple threads.