We have some work to be done within a thread which will be run on a server for a web app using Spring Boot .
What we want to happen is: 1) Work is submitted as our custom Runnable object 2) Work completes when it gets its turn (it's a database operation, and we don't need any return value except perhaps returning "Success" if the run() completed without exceptions)
However, in our JUnit tests, it seems all the tasks submitted to an ExecutorService or CompletionService disappear when the main thread is finished, unless we call take() every time we add a new task (since it blocks until a task is finished, this makes tasks run sequentially, which defeats the purpose) or if we maintain a list of futures and call a method to loop through the list and get() the value of each feature.
The latter option we don't think is ideal because as a server application, we will have requests constantly coming in from different users and don't know how to detect when we should be clearing out the list of futures.
Why do the threads silently disappear and what is a way around this?