public static ThreadPoolExecutor getBoundedThreadPoolExecutor ( int maxPoolSize , long keepAliveTime , TimeUnit unit , ThreadFactory tFactory ) { return new ThreadPoolExecutor ( 0 , maxPoolSize , keepAliveTime , unit , new SynchronousQueue < Runnable > ( ) , tFactory ) ; }
Create a bounded thread pool executor . The work queue is synchronous and can cause RejectedExecutionException if there is no available thread to take a new task .