I want to understand how ExecutorService acts as watchdog for the thread-pools that it creates.
Basically, as I understand, ExecutorService is just an object, it is not a "thread or process" which creates other threads.
Typically,for ThreadPoolExecutor:
threadPoolExecutor = (ThreadPoolExecutor) Executors.newFixedThreadPool(2);
// Now, requesting Executor Service to "execute" each submitted Tasks.
threadPoolExecutor.execute(runnable);
Likewise for ScheduleThreadPoolExecutor
scheduledThreadPool = Executors.newSingleThreadScheduledExecutor(threadFactory);
scheduledThreadPool.scheduleAtFixedRate(runnable, 2000, 3000, TimeUnit.MILLISECONDS);
Essentially, they are just objects, how are they able to , for example, "restart a thread if it dies".
I am not able to understand this, for example, in case of ScheduledThreadPoolExecutor we call method once for periodic action, after that , how that object is able to manage threads.
I did look into the code, I still have doubts as to how a object can manage all this? (creation of thread pools, submitting the Jobs to Queues, restarting threads in thread-pool and so on)