This document provides an overview of using executors to handle multithreading in Java. It discusses key classes and interfaces in the executors framework like Executor, ExecutorService, and Executors. Common thread pools like fixed thread pool and cached thread pool are mentioned. The document also summarizes techniques for naming threads, returning values from threads, creating daemon threads, checking thread status, terminating threads, and handling uncaught exceptions using both the thread and executor APIs. Finally, it covers scheduling tasks using both the timer/timerTask classes and executor service.
Abstraction is a process by which concepts are derived from the usage and classification of literal ("real" or "concrete") concepts.
Abstraction is a concept that acts as a super-categorical noun for all subordinate concepts, and connects any related concepts as a group, field, or category.
Java abstract class & abstract methods,Abstract class in java
Abstract classes are classes that contain one or more abstract methods. An abstract method is a method that is declared, but contains no implementation. Abstract classes may not be instantiated, and require subclasses to provide implementations for the abstract methods.
Abstraction is a process by which concepts are derived from the usage and classification of literal ("real" or "concrete") concepts.
Abstraction is a concept that acts as a super-categorical noun for all subordinate concepts, and connects any related concepts as a group, field, or category.
Java abstract class & abstract methods,Abstract class in java
Abstract classes are classes that contain one or more abstract methods. An abstract method is a method that is declared, but contains no implementation. Abstract classes may not be instantiated, and require subclasses to provide implementations for the abstract methods.
JSP technology has facilitated the segregation of the work of a Web designer and a Web developer.
A Web designer can design and formulate the layout for the Web page by using HTML.
On the other hand, a Web developer working independently can use java code and other JSP specific tags to code the business logic.
The simultaneous construction of the static and dynamic content facilitates development of quality applications with increased productivity.
JSP technology has facilitated the segregation of the work of a Web designer and a Web developer.
A Web designer can design and formulate the layout for the Web page by using HTML.
On the other hand, a Web developer working independently can use java code and other JSP specific tags to code the business logic.
The simultaneous construction of the static and dynamic content facilitates development of quality applications with increased productivity.
My presentation slides in KMS TechCon 2014, an internal technology event at KMS Technology Vietnam company.
"Java 8 is one of the most highly anticipated programming language updates in many years. Let me give you an introduction about its new features: Lambda expressions, Method references, Default Methods, Stream API, new JS Engine, new Date/Time API and more..."
Java 8 is coming soon. In this presentation I have outlined the major Java 8 features. You get information about interface improvements, functional interfaces, method references, lambdas, java.util.function, java.util.stream
Java Persistence API (JPA) - A Brief OverviewCraig Dickson
This is a lightning presentation given by Scott Rabon, a member of my development team. He presents a high level overview of the JPA based on his first exposure to it.
JUnit: A unit testing framework that is extensively used to test the code written in Java.
Unit testing is a type of software testing.
Software testing: The process of examining whether the software and its components meet the specified requirements
Other types of software testing are as shown.
At a time when Herbt Sutter announced to everyone that the free lunch is over (The Free Lunch Is Over: A Fundamental Turn Toward Concurrency in Software), concurrency has become our everyday life.A big change is coming to Java, the Loom project and with it such new terms as "virtual thread", "continuations" and "structured concurrency". If you've been wondering what they will change in our daily work or
whether it's worth rewriting your Tomcat-based application to super-efficient reactive Netty,or whether to wait for Project Loom? This presentation is for you.
I will talk about the Loom project and the new possibilities related to virtual wattles and "structured concurrency". I will tell you how it works and what can be achieved and the impact on performance
Understanding Framework Architecture using Eclipseanshunjain
Talk on Framework architectures given at SAP Labs India for Eclipse Day India 2011 - Code attached Here: https://sites.google.com/site/anshunjain/eclipse-presentations
Look past the square braces and the damned header files and Objective-C -- the essential language of iOS development -- really isn't that different from other object-oriented languages. Classes, single-inheritance, polymorphism, implementation hiding... check, check, check, and check. So it's really not that difficult for old Java / Python / Ruby / C++ dogs to learn new tricks once they install Xcode, right?
To be a competent Obj-C programmer, not that hard.
To be a great Obj-C programmer... now that's another story.
In this session, we will look at traits that are unique to Objective-C, the tricks that bring out the expressiveness and power of the language. We'll also look at how to write idiomatic code that will be easily understood and maintained by other Objective-C developers. We'll look at how Automatic Reference Counting resembles but is really nothing like Garbage Collection, how properties put plain old instance variables to shame, how we loosely couple classes with delegates and notification, how blocks help us un-block our code by simplifying asynchronicity, and more.
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf91mobiles
91mobiles recently conducted a Smart TV Buyer Insights Survey in which we asked over 3,000 respondents about the TV they own, aspects they look at on a new TV, and their TV buying preferences.
Generating a custom Ruby SDK for your web service or Rails API using Smithyg2nightmarescribd
Have you ever wanted a Ruby client API to communicate with your web service? Smithy is a protocol-agnostic language for defining services and SDKs. Smithy Ruby is an implementation of Smithy that generates a Ruby SDK using a Smithy model. In this talk, we will explore Smithy and Smithy Ruby to learn how to generate custom feature-rich SDKs that can communicate with any web service, such as a Rails JSON API.
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualityInflectra
In this insightful webinar, Inflectra explores how artificial intelligence (AI) is transforming software development and testing. Discover how AI-powered tools are revolutionizing every stage of the software development lifecycle (SDLC), from design and prototyping to testing, deployment, and monitoring.
Learn about:
• The Future of Testing: How AI is shifting testing towards verification, analysis, and higher-level skills, while reducing repetitive tasks.
• Test Automation: How AI-powered test case generation, optimization, and self-healing tests are making testing more efficient and effective.
• Visual Testing: Explore the emerging capabilities of AI in visual testing and how it's set to revolutionize UI verification.
• Inflectra's AI Solutions: See demonstrations of Inflectra's cutting-edge AI tools like the ChatGPT plugin and Azure Open AI platform, designed to streamline your testing process.
Whether you're a developer, tester, or QA professional, this webinar will give you valuable insights into how AI is shaping the future of software delivery.
Transcript: Selling digital books in 2024: Insights from industry leaders - T...BookNet Canada
The publishing industry has been selling digital audiobooks and ebooks for over a decade and has found its groove. What’s changed? What has stayed the same? Where do we go from here? Join a group of leading sales peers from across the industry for a conversation about the lessons learned since the popularization of digital books, best practices, digital book supply chain management, and more.
Link to video recording: https://bnctechforum.ca/sessions/selling-digital-books-in-2024-insights-from-industry-leaders/
Presented by BookNet Canada on May 28, 2024, with support from the Department of Canadian Heritage.
Connector Corner: Automate dynamic content and events by pushing a buttonDianaGray10
Here is something new! In our next Connector Corner webinar, we will demonstrate how you can use a single workflow to:
Create a campaign using Mailchimp with merge tags/fields
Send an interactive Slack channel message (using buttons)
Have the message received by managers and peers along with a test email for review
But there’s more:
In a second workflow supporting the same use case, you’ll see:
Your campaign sent to target colleagues for approval
If the “Approve” button is clicked, a Jira/Zendesk ticket is created for the marketing design team
But—if the “Reject” button is pushed, colleagues will be alerted via Slack message
Join us to learn more about this new, human-in-the-loop capability, brought to you by Integration Service connectors.
And...
Speakers:
Akshay Agnihotri, Product Manager
Charlie Greenberg, Host
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...UiPathCommunity
💥 Speed, accuracy, and scaling – discover the superpowers of GenAI in action with UiPath Document Understanding and Communications Mining™:
See how to accelerate model training and optimize model performance with active learning
Learn about the latest enhancements to out-of-the-box document processing – with little to no training required
Get an exclusive demo of the new family of UiPath LLMs – GenAI models specialized for processing different types of documents and messages
This is a hands-on session specifically designed for automation developers and AI enthusiasts seeking to enhance their knowledge in leveraging the latest intelligent document processing capabilities offered by UiPath.
Speakers:
👨🏫 Andras Palfi, Senior Product Manager, UiPath
👩🏫 Lenka Dulovicova, Product Program Manager, UiPath
Neuro-symbolic is not enough, we need neuro-*semantic*Frank van Harmelen
Neuro-symbolic (NeSy) AI is on the rise. However, simply machine learning on just any symbolic structure is not sufficient to really harvest the gains of NeSy. These will only be gained when the symbolic structures have an actual semantics. I give an operational definition of semantics as “predictable inference”.
All of this illustrated with link prediction over knowledge graphs, but the argument is general.
Elevating Tactical DDD Patterns Through Object CalisthenicsDorra BARTAGUIZ
After immersing yourself in the blue book and its red counterpart, attending DDD-focused conferences, and applying tactical patterns, you're left with a crucial question: How do I ensure my design is effective? Tactical patterns within Domain-Driven Design (DDD) serve as guiding principles for creating clear and manageable domain models. However, achieving success with these patterns requires additional guidance. Interestingly, we've observed that a set of constraints initially designed for training purposes remarkably aligns with effective pattern implementation, offering a more ‘mechanical’ approach. Let's explore together how Object Calisthenics can elevate the design of your tactical DDD patterns, offering concrete help for those venturing into DDD for the first time!
Key Trends Shaping the Future of Infrastructure.pdfCheryl Hung
Keynote at DIGIT West Expo, Glasgow on 29 May 2024.
Cheryl Hung, ochery.com
Sr Director, Infrastructure Ecosystem, Arm.
The key trends across hardware, cloud and open-source; exploring how these areas are likely to mature and develop over the short and long-term, and then considering how organisations can position themselves to adapt and thrive.
Epistemic Interaction - tuning interfaces to provide information for AI supportAlan Dix
Paper presented at SYNERGY workshop at AVI 2024, Genoa, Italy. 3rd June 2024
https://alandix.com/academic/papers/synergy2024-epistemic/
As machine learning integrates deeper into human-computer interactions, the concept of epistemic interaction emerges, aiming to refine these interactions to enhance system adaptability. This approach encourages minor, intentional adjustments in user behaviour to enrich the data available for system learning. This paper introduces epistemic interaction within the context of human-system communication, illustrating how deliberate interaction design can improve system understanding and adaptation. Through concrete examples, we demonstrate the potential of epistemic interaction to significantly advance human-computer interaction by leveraging intuitive human communication strategies to inform system design and functionality, offering a novel pathway for enriching user-system engagements.
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Tobias Schneck
As AI technology is pushing into IT I was wondering myself, as an “infrastructure container kubernetes guy”, how get this fancy AI technology get managed from an infrastructure operational view? Is it possible to apply our lovely cloud native principals as well? What benefit’s both technologies could bring to each other?
Let me take this questions and provide you a short journey through existing deployment models and use cases for AI software. On practical examples, we discuss what cloud/on-premise strategy we may need for applying it to our own infrastructure to get it to work from an enterprise perspective. I want to give an overview about infrastructure requirements and technologies, what could be beneficial or limiting your AI use cases in an enterprise environment. An interactive Demo will give you some insides, what approaches I got already working for real.
3. Disclaimer
This presentation does not cover the basics of Java Multithreading
It’s focus is primarily on the Executors Framework
It is used in the online video course on Udemy – “Efficient Java
Multithreading with Executors”
It’s probably a bit boring as it contains a lot of text but no funny
images and no code listings
The matter in the slides is actually explained in the video course
(sample videos can be viewed on You-Tube or Udemy)
Still strong? Let’s roll!
4. About me!
My name is Arun Kumar Mehra.
Nearly 13 years in Software Industry architecting and
developing Enterprise applications
Worked in diverse domains – Life Insurance, Investment
Banking and Telecommunications
Mostly used Java/JEE technologies
Diehard fan of Open Source especially, Java, Groovy,
OSGi and Eclipse RCP/RAP
5. Pre-requisites
Good knowledge of Java and basic knowledge of
multithreading required …
o Why multithreading
o Scenarios where multithreading is useful (and where it is not!)
o Difference between thread-of-execution and Thread class
o Various execution-thread states
o Thread class operations
o Etc.
6. Course Structure
Introduction
Creating and Running threads
Naming threads
Returning values from threads
Creating daemon threads
Checking threads for ‘life’
01
02
03
04
05
06
Terminating threads
Handling Uncaught Exceptions
Waiting for other threads to
terminate
Scheduling tasks
07
08
09
10
8. Starting Threads – Basic Mechanism
Thread class object
Runnable interface implementation or ‘The Task’
Invocation of start() method on the Thread object
To run a task in a separate thread-of-execution, three
things are required:
9. Creating Threads Using Threads API
Quite a few ways. Difference lies in:
The mechanism using which:
o The Thread object is created
o The Task is created
The way these two objects are brought together and made to
collaborate
10. Running Threads Using Executors API
Only one way!
Create task definition class
Provide task object to an Executor Service
11. Executors API Overview
Preferred way of running tasks...
Uses thread-pools
Allocates heavy-weight threads upfront
Decouples task-submission from thread-creation-and-management
Each thread in the pool executes multiple tasks one-by-one
A tasks-queue holds the tasks
Threads are stopped when the Executor Service is stopped
13. Important Classes/Interfaces
Some frequently referred classes/interfaces while using
Executors framework:
Executor (I)
ExecutorService (I)
<T> Future<T> submit (Callable<T> task);
Future<?> submit (Runnable task);
void shutdown ( );
List<Runnable> shutdownNow ( );
boolean isShutdown ( );
…
14. Important Classes/Interfaces
Some frequently referred classes/interfaces while using
Executors framework:
Executor (I)
ExecutorService (I)
Executors (C)
public static ExecutorService newFixedThreadPool (int nThreads);
public static ExecutorService newCachedThreadPool ( );
public static ExecutorService newSingleThreadExecutor ( );
public static ExecutorService newSingleThreadScheduledExecutor ( );
…
15. Important Classes/Interfaces
Some frequently referred classes/interfaces while using
Executors framework:
Executor (I)
ExecutorService (I)
Executors (C)
Future (I)
V get ( ) throws InterruptedException , ExecutionException;
boolean isDone ( );
…
16. Available Thread-Pools
Many types of thread-pools available out-of-the-box:
Fixed Thread Pool
Cached Thread Pool
Single Thread Executor (technically not a ‘pool’)
Scheduled Thread Pool
Single Thread Scheduled Executor (technically not a ‘pool’)
18. What’s In A Name?
‘Thread-0’, ‘Thread-1’, ‘Thread-2’ – not very helpful in identifying
the threads
More useful names would be:
o Directory-Scanner-Thread
o Timer-Thread
o Cache-Invalidating-Thread
Helps in identifying special threads while debugging multi-threaded
applications
Why would you want to name threads …
19. Naming Normal Threads
From within the task – at ‘thread-running’ time
At ‘thread-creation’ time
Java provides a couple of opportunities …
20. Naming Executor Threads
From within the task - at ‘thread-running’ time. Similar to the
technique that was used for renaming normal threads.
Specify the thread-naming strategy at ‘executor-creation’ time
Two ways …
21. Default Names of Executor Threads
“pool-N-thread-M”
Internal pool-sequence-no. in the
JVM. Incremented every time a new
executor-pool is created!
Internal thread-sequence-no. inside
an executor-pool. Incremented every
time a new thread is created!
23. Returning Values Using Normal Threads
No language level support in normal Threads but there is support
in Executors
A few ways for normal threads – see code
CTM: Values are returned from Tasks and not Threads!
24. Returning Values Using Executors
Use Callable<T> instead of Runnable
o Override method: public T call() throws Exception
ExecutorService.submit(Callable c)
Call to submit() returns a Future<T>
Task result can be retrieved using “T Future.get()” method
Out-of-the-box support provided by Java …
25. Processing Tasks’ Results in Order of Completion
CompletionService<V> (I)
ExecutorCompletionService<V> (C)
Use the following …
Future<V> submit (Callable<V> task)
Future<V> submit (Runnable task, V result)
Future<V> take ( )
Future<V> poll ( )
27. Daemon Threads – What and Why?
Killed by the JVM as soon as no user thread is running any longer
o Can be stopped normally too – just like normal threads
‘main’ thread is a ‘user’ thread – not ‘daemon’
Any kind of logic as desired can be put in daemon threads. E.g.:
o Directory-watcher-thread
o Socket-reader-thread
o Long-calculation-thread
Background and/or service providing threads …
28. Creating ‘Daemon’ Threads
void Thread.setDaemon(boolean on)
o Also used in Executors API
For Executors, implement a ThreadFactory and manipulate the
thread there to make it ‘daemon’
Thread class provides a method …
30. Checking Threads for ‘Life’ - Threads API
Use the method: boolean Thread.isAlive()
Will return true if:
o … the thread is still running
Will return false in the following scenarios:
o If the thread has not been started yet i.e Thread.start() has not been called yet or;
o If the thread has terminated – irrespective of whether it has successfully finished
executing its task or not
A thread is live if it has started but not terminated yet!!!
31. Checking Threads for ‘Life’ – Executors API
Actually we are interested in task completion!!!
Use the method: boolean Future.isDone()
Will return true if:
o … the task execution is completed - whether normally, or with exception or with
cancellation
Will return false if:
o … the task execution has not been completed yet – in fact, it may not even have
started yet!
Are we really interested in a thread being live …???
32. This deck is part of the full-fledged video course on :
EFFICIENT JAVA MULTITHREADING
WITH
EXECUTORS
Visit: Course
34. Terminating Normal Threads
Terminating at non-blocked portions in the task:
o Using a method coded for this purpose in the task
o Using interrupts:
void Thread.interrupt() – usually called by another thread on the thread-to-be-
interrupted
static boolean Thread.interrupted() – to be called from inside the interrupted thread
boolean Thread.isInterrupted() – to be called by another thread on the interrupted
thread
Terminating at points in the task where the thread is
blocked:
o Using interrupts – same methods as above
There are a few ways …
35. Terminating Individual Executor Tasks
Terminating at non-blocked portions in the task:
o Using a method coded for this purpose in the task
o Using interrupts:
boolean Future.cancel(boolean mayInterruptIfRunning) – to be called by the class holding
the Future ref.
static boolean Thread.interrupted() – to be called from inside the interrupted task
boolean Future.isCancelled() – to be called on the Future outside the interrupted task
Terminating at points in the task where the thread is
blocked:
o Using interrupts – same methods as above
There are a few ways …
36. Terminating All Executor Tasks in One-Shot
Use: List<Runnable> ExecutorService.shutdownNow()
o Uses interrupts under the hood
o Returns a list of tasks that were awaiting execution yet
Interrupting may terminate blocked as well as non-blocked tasks
Tasks must be coded to properly handle the interrupts
To await termination after shutting down, use:
o boolean ExecService.awaitTermination(long timeout, TimeUnit unit)
Uses the same concepts as discussed previously …
38. Uncaught Exceptions in Threads
Implement Thread.UncaughtExceptionHandler interface
o Only one method: void uncaughtException(Thread t, Throwable e)
Three ways to use UncaughtExceptionHandler:
o Set as default handler for all the threads in the system
static void Thread.setDefaultUncaughtExceptionHandler(UncaughtExceptionHandler eh)
o Set different handlers for different threads
void Thread.setUncaughtExceptionHandler(UncaughtExceptionHandler eh)
o Use a combination of default-handler and thread-specific-handlers
Leaking Exceptions from threads cannot be caught
directly …
39. Uncaught Exceptions in Executors
Implement Thread.UncaughtExceptionHandler interface
o Only one method: void uncaughtException(Thread t, Throwable e)
Three ways to use UncaughtExceptionHandler:
o Set as default handler for all the threads in the system
static void Thread.setDefaultUncaughtExceptionHandler(UncaughtExceptionHandler eh)
o Set different handlers for different threads
Implement a ThreadFactory and;
Use void Thread.setUncaughtExceptionHandler(UncaughtExceptionHandler eh)
o Use a combination of default-handler and thread-specific-handlers
Similar ways of handling like the normal threads …
41. Waiting for Normal-Threads to Finish
Previously discussed techniques:
o boolean Thread.isAlive()
To be called multiple times till you get a ‘false’
Wastage of CPU cycles
o wait() and notify() mechanism
To be coded manually in the tasks by the programmer
A little difficult to get right
Third technique:
o void Thread.join()
In-built mechanism – works just like wait() and notify()
Easy to use
Suspend the current thread so that it continues only after some
other thread(s) have finished …
42. Waiting for Executor Tasks to Finish
Use java.util.concurrent.CountDownLatch
An object of CountDownLatch is shared by the waiting tasks and
the awaited tasks.
o Waiting-tasks call void await() on the latch
o Awaited-tasks call void countdown() on the latch after finishing their
executions
o When the count reaches zero, waiting tasks are released, thereby, bringing
them out of suspended state and enabling their execution again.
Suspend the current task so that it continues only after some
other task(s) have finished …
44. Scheduling Tasks using Threads-API
java.util.Timer
o Spawns a thread for executing the tasks
o Also contains scheduling logic
java.util.TimerTask
o Implements Runnable interface
o Represents the task
o Should be short-lived for repeated
executions
For all scheduling needs, Threads-API provides two classes …
void schedule(TimerTask task, Date time)
void schedule(TimerTask task, long delay)
void schedule(TimerTask task, Date firstTime, long period)
void schedule(TimerTask task, long delay, long period)
void scheduleAtFixedRate(TimerTask task, Date firstTime, long period)
void scheduleAtFixedRate(TimerTask task, long delay, long period)
void cancel()
long scheduledExecutionTime()
boolean cancel()
45. The “java.util.Timer” Class
Single task-execution-thread per Timer object
Timer tasks should complete quickly
Always call Timer.cancel() when application is shutting down;
otherwise it may cause memory leak
Don’t schedule any more tasks on the Timer after cancelling it
Timer class is thread-safe
Timer class does not offer any real-time guarantees
Few things worth stressing upon about the Timer class …
46. One-Time Execution in Future - Threads-API
Two Timer methods for scheduling one-time execution:
o void schedule(TimerTask task, Date time)
o void schedule(TimerTask task, long delay)
Use Timer and TimerTask classes …
47. Repeated Fixed-Delay Executions – Threads API
Timer and TimerTask only, are used …
Two methods in Timer class:
o void schedule(TimerTask task, long delay, long period)
o void schedule(TimerTask task, Date firstTime, long period)
Next execution is scheduled when the current one begins
Each execution is schedule relative to the actual start time of the
previous one
Start-times drift forward over long runs
o Hence, frequency of executions becomes lower than that specified
Appropriate for activities that require ‘smoothness’ over short
periods of time e.g. blinking cursor, hourly chimes, etc.
48. Repeated Fixed-Rate Executions – Threads API
Timer and TimerTask only, are used …
Two methods in Timer class:
o void scheduleAtFixedRate(TimerTask task, long delay, long period)
o void scheduleAtFixedRate(TimerTask task, Date firstTime, long period)
Next execution is scheduled when the current one begins
Each execution is schedule relative to the scheduled start time of
the first execution
Start-times DO NOT drift forward over long runs
o Hence, frequency of executions remains constant
Appropriate for activities that are sensitive to ‘absolute time’ and
accurate frequency of executions
49. Scheduling Tasks - Executors-API
Available pools:
o Single-thread-scheduled-executor
o Scheduled-thread-pool
Created using Executors (C)
ScheduledExecutorService (I)
o Extends ExecutorService (I)
ScheduledFuture (I). Extends:
o Future (I)
o Delayed (I)
Special thread-pool(s) provided by Executors for scheduling tasks …
ScheduledFuture<?> schedule(Runnable command, long delay,
TimeUnit unit)
<V> ScheduledFuture<V> schedule(Callable<V> callable, long delay,
TimeUnit unit)
ScheduledFuture<?> scheduleWithFixedDelay(Runnable command,
long initialDelay, long delay, TimeUnit unit)
ScheduledFuture<?> scheduleAtFixedRate(Runnable command,
long initialDelay, long period, TimeUnit unit)
static ScheduledExecutorService newSingleThreadScheduledExecutor()
static ScheduledExecutorService newScheduledThreadPool(int corePoolSize)
long getDelay(TimeUnit unit)
50. One Time Execution in Future – Executors API
ScheduledExecutorService is used …
Two methods:
o ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit)
o ScheduledFuture<?> schedule(Callable<V> callable, long delay, TimeUnit unit)
Executions can be scheduled using a single-thread-executor or
scheduled-thread-pool
No need to extend TimerTask. Normal Runnables and Callables only
are needed!
51. Repeated Fixed-Delay Executions – Executors API
ScheduledExecutorService is used …
Only one method:
o ScheduledFuture<?> scheduleWithFixedDelay(Runnable command, long
initialDelay, long delay, TimeUnit unit)
Executions can be scheduled using a single-thread-executor or
scheduled-thread-pool
Each execution is schedule relative to the termination-time of the
previous execution
o Start-times drift forward over long runs
o Hence, frequency of executions becomes lower than that specified
Only Runnables can be scheduled – no Callables!
52. Repeated Fixed-Rate Executions – Executors API
ScheduledExecutorService is used …
Only one method:
o ScheduledFuture<?> scheduleAtFixedRate(Runnable command, long
initialDelay, long period, TimeUnit unit)
Executions can be scheduled using a single-thread-executor or
scheduled-thread-pool
Each execution is schedule relative to the scheduled start time of
the first execution
o Start-times DO NOT drift forward over long runs
o Hence, frequency of executions remains constant
Only Runnables can be scheduled – no Callables!