Java newFixedThreadPool example
GIAN Tutorials
8:15 AM
Executor’s newFixedThreadPool factory method : This method returns thread pool executor whose maximum size(let’s say n threads) is fixed.If all n threads are busy performing the task and additional tasks are submitted, then they will have to be in the queue until a thread is available. Syntax: 1 2 3 ExecutorService executorService = Executors . newFixedThreadPool ( noOfThreads ) ; Java newFixedThreadPool example: Let’s create a very simple example. Step 1: Create a Runnable task named “LoopTask.java”. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 package org . arpit . java2blog ; public class LoopTask implements Runnable { private String loopTaskName ; public LoopTask ( String loopTaskName ) { super ( ) ; this . loopTaskName = loopTaskName ; } @ Override public void run ( ) { System .