Your own Thread Pool
"Create your own thread pool" - A typical interview question, asked to check if you have a basic understanding of Thread Pool, Runnable, and the disadvantages of creating a new Thread for each Task. ThreadPool is made up of a number of threads, identified by the core thread pool size. Once you start the ThreadPool, all the threads start running, waiting for the task. Each task or Runnable that you submit to the ThreadPool is executed by the existing threads of the ThreadPool. Creating a thread is expensive, so it is advisable to have a ThreadPool which manages the tasks. Here is a program which creates its own ThreadPool - MyThreadPool. import java.util.concurrent.ArrayBlockingQueue ; import java.util.concurrent.BlockingQueue ; class MyThreadPool { private int corePoolSize ; private MyThread tPool []; private BlockingQueue < Runnable > queue = new ArrayBlockingQueue <>(1024); public MyThreadPool ( int corePoolSize ) { thi...