How to implement blocking ThreadPoolExecutor
问题 I need to implement blocking ThreadPoolExecutor . This is a very crucial requirement in our enterprise application. It would do something like if ThreadPoolExecutor.submit() or ThreadPoolExecutor.execute() method blocks until a thread gets freed up for picking up a new task. But in current implementation ThreadPoolExecutor.submit() and ThreadPoolExecutor.execute() methods throw RejectedExecutionException exception if all pooled threads get busy. For example following code throws