Best way to wait on tasks to complete before adding new ones to threadpool in Java?
问题 I want to use something like a ThreadPoolExecutor to manage running a bunch of tasks on available threads. These tasks are all of the same type but deal with different accounts. New tasks for these accounts can be added at regular intervals and I want it to check and not allow the new tasks to start until the old tasks for the same account have already completed. What's the best way to do this? EXAMPLE Task for account "234" is started (via ThreadPoolExecutor.execute()) Task for account "238"