M
M
Murad Kasp2021-12-01 19:37:04
Java
Murad Kasp, 2021-12-01 19:37:04

How to properly organize work in a multi-threaded program?

There is an application that spawns a number of threads using the ExecutorService. Each thread is one task, the task has an id for identification. Two tasks (threads) with the same id cannot exist at the same time.
How to gracefully get out of the situation?
I have in mind to use the object of which to pass to the "task" method, and after the task is completed, at the end, remove the entry with the corresponding id from the list. Collections.synchronizedList(new ArrayList<>())

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question