0

Say I am using a thread pool with a fixed number of threads that can run at the same time. So for example:

   ThreadPoolExecutor executor = Executors.newFixedThreadPool(10);

Now say this executor is full. Is there a way to tell the thread that has access to this thread pool to wait until a space becomes available?

Yavor
  • 5
  • 3
  • 1
    Why would the current thread need to wait? If it doesn't care about the job's result, it also shouldn't care that there's no space yet. If it does need the job's result, just use the `Future` that's returned when you submit the task. Again, the submitter shouldn't care that there's no space yet, as long as it gets the results. – Rob Spoor Jun 18 '22 at 14:51
  • @RobSpoor Well Im dealing with a very specific use case where I need the main thread to wait only when the threadpool is full. – Yavor Jun 18 '22 at 15:23

0 Answers0