A good finding Gayan! Will this exception thrown to the execute() method caller? If so we will need to use this.
Thanks On Thu, Aug 20, 2015 at 9:48 PM, Gayan Gunarathne <gay...@wso2.com> wrote: > Hi All, > > In our current code base , we are creating a execute service with fixed > size.Even we have used the separate execute services for the each component > , we can't guarantee the no of threads. That may leads to throw the > "RejectedExecutionHandler" when no of threads exceeds the predefined > executor service size. > > Shall we use the blocking queue as following to overcome this issue. > > final BlockingQueue<Runnable> queue = > new ArrayBlockingQueue<Runnable>(QUEUE_SIZE);ThreadPoolExecutor > threadPool = new ThreadPoolExecutor(NUM_THREADS, NUM_THREADS, > 0L, TimeUnit.MILLISECONDS, > queue);threadPool.setRejectedExecutionHandler(new RejectedExecutionHandler() { > public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) { > executor.getQueue().put(r); > }}); > > By default the ThreadPoolExecutor will throw an exception when it size is > filled.But with this this we can block the job if the queue is full without > throwing the exception. WDYT? > > Thanks, > Gayan > > > > -- > > Gayan Gunarathne > Technical Lead, WSO2 Inc. (http://wso2.com) > Committer & PMC Member, Apache Stratos > email : gay...@wso2.com | mobile : +94 775030545 <%2B94%20766819985> > > > -- Imesh Gunaratne Senior Technical Lead, WSO2 Committer & PMC Member, Apache Stratos