SlideShare a Scribd company logo
Java Concurrent
Anubhav Goyal
Agenda
● What is concurrency?
● About Concurrent Package
● Thread Pool
● Executor
● Future
● Callable
● Demo
Concurrency
Concurrency is the ability to run several
programs or several parts of a program in
parallel. If a time consuming task can be
performed asynchronously or in parallel, this
improve the throughput and the interactivity of
the program.
Councurrent Package
It released with jdk 1.5. It contains many
classes and interfaces for threading. There try
to overcome from the limits of traditional
Threading. There are more pacakges inside
java.util.concurrent package, these are:
● java.util.concurrent.atomic
● java.util.concurrent.locks
Thread Pool
Thread Pools are useful when you need to limit
the number of threads running in your
application at the same time. There is a
performance overhead associated with starting
a new thread, and each thread is also allocated
some memory for its stack etc.
Executor
Executors framework
(java.util.concurrent.Executor), released with
the JDK 5 in package java.util.concurrent is
used to run the Runnable objects without
creating new threads every time and mostly re-
using the already created threads.
The ExecutorService has the following
implementation in concurrent package:
● ThreadPoolExecutor
● ScheduledThreadPoolExecutor
Future
When we submit a long running task to
ExecutorService, it returns a Future object
immediately. This Future object can be used to
query task completion and getting result of
computation.
Using Java Future object, we can find out the status
of the Callable task and get the returned Object. It
provides get() method that can wait for the Callable
to finish and then return the result.
Callable
Java Callable interface use Generic to define
the return type of Object. Executors class
provide useful methods to execute Java
Callable in a thread pool. Since callable tasks
run in parallel, we have to wait for the returned
Object.
Link for demo
https://github.com/NexThoughts/Java-
Concurrent

More Related Content

PPTX
Introduction to Spring Framework
PDF
Spring Framework
PPTX
Java Spring Framework
PPTX
Spring Framework Rohit
PPTX
Spring MVC framework
PDF
Introduction to Spring Framework
PPTX
Java spring ppt
PDF
Java spring framework
Introduction to Spring Framework
Spring Framework
Java Spring Framework
Spring Framework Rohit
Spring MVC framework
Introduction to Spring Framework
Java spring ppt
Java spring framework

What's hot (20)

ODP
Introduction to Spring Framework and Spring IoC
PDF
Getting Reactive with Spring Framework 5.0’s GA release
PPT
Spring introduction
PPTX
Introduction to Ibatis by Rohit
PDF
Spring framework
PPTX
Spring Framework
PDF
Spring framework core
PDF
Spring Framework Tutorial | VirtualNuggets
PDF
Spring Framework Training Course
PDF
Spring boot jpa
PDF
Spring mvc
PPT
Spring Framework
PDF
Spring framework
PPTX
Next stop: Spring 4
PDF
Spring - CDI Interop
PDF
Spring aop
PDF
Spring MVC Framework
PDF
Spring Framework 4.0 to 4.1
PPSX
Spring - Part 1 - IoC, Di and Beans
Introduction to Spring Framework and Spring IoC
Getting Reactive with Spring Framework 5.0’s GA release
Spring introduction
Introduction to Ibatis by Rohit
Spring framework
Spring Framework
Spring framework core
Spring Framework Tutorial | VirtualNuggets
Spring Framework Training Course
Spring boot jpa
Spring mvc
Spring Framework
Spring framework
Next stop: Spring 4
Spring - CDI Interop
Spring aop
Spring MVC Framework
Spring Framework 4.0 to 4.1
Spring - Part 1 - IoC, Di and Beans
Ad

Viewers also liked (20)

PPTX
Grails Plugins(Console, DB Migration, Asset Pipeline and Remote pagination)
PDF
Introduction to thymeleaf
PPT
OAuth2 Protocol with Grails Spring Security
PPT
Grails Plugins
PPTX
Grails Services
PPTX
PPTX
Config BuildConfig
PPT
Linux Introduction
PPT
PPTX
Grails Custom Plugin
PPTX
Advanced criteria queries
ODP
Elastic search
PDF
Grails audit logging
PPTX
Introduction to redis
PPT
Introduction to Grails
ODP
Grails Plugins(Console, DB Migration, Asset Pipeline and Remote pagination)
Introduction to thymeleaf
OAuth2 Protocol with Grails Spring Security
Grails Plugins
Grails Services
Config BuildConfig
Linux Introduction
Grails Custom Plugin
Advanced criteria queries
Elastic search
Grails audit logging
Introduction to redis
Introduction to Grails
Ad

Similar to Java Concurrent (20)

PPTX
parallel-asynchronous-programming-java.pptx
ODP
Concurrent Programming in Java
PPT
Java Core | Modern Java Concurrency | Martijn Verburg & Ben Evans
PDF
Completable future
PPT
cs4240-multithreading.ppt presentation on multi threading
PDF
Concurrency-5.pdf
PPTX
MULTITHREADING PROGRAMMING AND I/O THREAD
KEY
Modern Java Concurrency (OSCON 2012)
PPTX
Java Concurrency and Asynchronous
PDF
Loom Virtual Threads in the JDK 19
ODP
Java concurrency
PDF
Java concurrency model - The Future Task
PPTX
Parallel Programming Hands-On Presentation
PDF
Flavors of Concurrency in Java
PPTX
Completable Future java 8 Features with example
PDF
Asynchronous programming with Java & Spring
PDF
Looming Marvelous - Virtual Threads in Java Javaland.pdf
PDF
1. learning programming with JavaThreads.pdf
PPTX
Multithreading and concurrency in android
PPTX
Think Async in Java 8
parallel-asynchronous-programming-java.pptx
Concurrent Programming in Java
Java Core | Modern Java Concurrency | Martijn Verburg & Ben Evans
Completable future
cs4240-multithreading.ppt presentation on multi threading
Concurrency-5.pdf
MULTITHREADING PROGRAMMING AND I/O THREAD
Modern Java Concurrency (OSCON 2012)
Java Concurrency and Asynchronous
Loom Virtual Threads in the JDK 19
Java concurrency
Java concurrency model - The Future Task
Parallel Programming Hands-On Presentation
Flavors of Concurrency in Java
Completable Future java 8 Features with example
Asynchronous programming with Java & Spring
Looming Marvelous - Virtual Threads in Java Javaland.pdf
1. learning programming with JavaThreads.pdf
Multithreading and concurrency in android
Think Async in Java 8

More from NexThoughts Technologies (20)

PDF
PDF
Docker & kubernetes
PDF
Apache commons
PDF
Microservice Architecture using Spring Boot with React & Redux
PDF
Solid Principles
PDF
Introduction to TypeScript
PDF
Smart Contract samples
PDF
My Doc of geth
PDF
Geth important commands
PDF
Ethereum genesis
PPTX
Springboot Microservices
PDF
An Introduction to Redux
PPTX
Google authentication
Docker & kubernetes
Apache commons
Microservice Architecture using Spring Boot with React & Redux
Solid Principles
Introduction to TypeScript
Smart Contract samples
My Doc of geth
Geth important commands
Ethereum genesis
Springboot Microservices
An Introduction to Redux
Google authentication

Recently uploaded (20)

PPTX
Essential Infomation Tech presentation.pptx
PDF
How Creative Agencies Leverage Project Management Software.pdf
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PDF
System and Network Administration Chapter 2
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PDF
Understanding Forklifts - TECH EHS Solution
PPTX
Odoo POS Development Services by CandidRoot Solutions
PDF
Softaken Excel to vCard Converter Software.pdf
PDF
medical staffing services at VALiNTRY
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PPTX
Operating system designcfffgfgggggggvggggggggg
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PDF
Nekopoi APK 2025 free lastest update
PDF
top salesforce developer skills in 2025.pdf
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
Essential Infomation Tech presentation.pptx
How Creative Agencies Leverage Project Management Software.pdf
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
System and Network Administration Chapter 2
Which alternative to Crystal Reports is best for small or large businesses.pdf
Understanding Forklifts - TECH EHS Solution
Odoo POS Development Services by CandidRoot Solutions
Softaken Excel to vCard Converter Software.pdf
medical staffing services at VALiNTRY
Wondershare Filmora 15 Crack With Activation Key [2025
Operating system designcfffgfgggggggvggggggggg
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
How to Migrate SBCGlobal Email to Yahoo Easily
Design an Analysis of Algorithms I-SECS-1021-03
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
How to Choose the Right IT Partner for Your Business in Malaysia
Nekopoi APK 2025 free lastest update
top salesforce developer skills in 2025.pdf
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...

Java Concurrent

  • 2. Agenda ● What is concurrency? ● About Concurrent Package ● Thread Pool ● Executor ● Future ● Callable ● Demo
  • 3. Concurrency Concurrency is the ability to run several programs or several parts of a program in parallel. If a time consuming task can be performed asynchronously or in parallel, this improve the throughput and the interactivity of the program.
  • 4. Councurrent Package It released with jdk 1.5. It contains many classes and interfaces for threading. There try to overcome from the limits of traditional Threading. There are more pacakges inside java.util.concurrent package, these are: ● java.util.concurrent.atomic ● java.util.concurrent.locks
  • 5. Thread Pool Thread Pools are useful when you need to limit the number of threads running in your application at the same time. There is a performance overhead associated with starting a new thread, and each thread is also allocated some memory for its stack etc.
  • 6. Executor Executors framework (java.util.concurrent.Executor), released with the JDK 5 in package java.util.concurrent is used to run the Runnable objects without creating new threads every time and mostly re- using the already created threads.
  • 7. The ExecutorService has the following implementation in concurrent package: ● ThreadPoolExecutor ● ScheduledThreadPoolExecutor
  • 8. Future When we submit a long running task to ExecutorService, it returns a Future object immediately. This Future object can be used to query task completion and getting result of computation. Using Java Future object, we can find out the status of the Callable task and get the returned Object. It provides get() method that can wait for the Callable to finish and then return the result.
  • 9. Callable Java Callable interface use Generic to define the return type of Object. Executors class provide useful methods to execute Java Callable in a thread pool. Since callable tasks run in parallel, we have to wait for the returned Object.