Java ScheduledThreadPoolExecutor – Scheduling With ExecutorService

ScheduledThreadPoolExecutor in Java adds functionality to schedule commands to run after a given delay, or to execute periodically. Since ScheduledThreadPoolExecutor is an ExecutorService so it uses thread from a thread pool to execute tasks. Table of contents Java ScheduledThreadPoolExecutor Java ScheduledThreadPoolExecutor constructors Creating ScheduledThreadPoolExecutor instance using Executors factory methods Scheduling…

Continue reading

Java Executor Tutorial – Executor, ExecutorService, ScheduledExecutorService

In this Java executor tutorial you’ll learn how to use Executor, ExecutorService, ScheduledExecutorService and their thread pool implementations to effectively manage threads in a large scale application. Table of contents Java Executor API Java Executor interface Java ExecutorService interface Java ScheduledExecutorService interface Java Executor implementation classes Creating executors using Executors…

Continue reading

Sleep Method in Java Multi-Threading

Thread.sleep() method in Java multi-threading causes the currently executing thread to suspend execution for a specified period. In Java Thread class there are two overloaded sleep() methods- static void sleep(long millis) throws InterruptedException– Causes the currently executing thread to sleep for the specified number of milliseconds. static void sleep(long millis,…

Continue reading