SlideShare une entreprise Scribd logo
1  sur  11
Java concurrency API
By Franck Benault
Created 06/12/2015
Last update 22/11/2015
Java concurrency introduction
● Parallelism can speed up you program
– But is Java the best language for concurrency ?
Java concurrency links
● My examples in Github
– https://github.com/franck-benault/test-concurrence
Java concurrency plan
Goal of this presentation
● Goal
– Very simple presentation
● Focus on ExecutorService
Java concurrency : Basics threads
● Principle
– Class Worker implemented Runnable interface
– Worker w = new Worker(...) ;
– Thread t = new Thread(w) ;
– t.start() ;
– t.join() ; //wait until the end of the thread
● Problems
– Run() method does not return any information (return value, exception)
– How to manage a pool of threads ?
– Do not use this way anymore !
Java concurrency : Sleep
● Old way
– Thread.sleep(100);
● Since Java5
– TimeUnit.MILLISECONDS.sleep(100);
Java concurrency : show threads
with jvisualVM
Java concurrency : Basics
isSynchronized
● Key word
– On a bloc (with a parameter)
– On a method
● Thread safe
Java concurrency :
ExcecutorService
● Management of a pool of threads
● Accept Callable and Runnable
ExecutorService executor;
executor = Executors.newFixedThreadPool(threadPoolSize);
WorkerThread workerThread = new WorkerThread(...);
executor.submit(workerThread);
...
executor.shutdown();
while (!executor.isTerminated()) Thread.sleep(10);
Conclusion
● Let's start with concurrency in Java

Contenu connexe

Tendances

Making react more like rails
Making react more like railsMaking react more like rails
Making react more like railsLuke Morton
 
MyCPAN ( LA.pm, September 2007 )
MyCPAN ( LA.pm, September 2007 )MyCPAN ( LA.pm, September 2007 )
MyCPAN ( LA.pm, September 2007 )brian d foy
 
PPW2007 - Continuity Project
PPW2007 - Continuity ProjectPPW2007 - Continuity Project
PPW2007 - Continuity Projectawwaiid
 
Ruby vs Node ShiningRay Shanghai
Ruby vs Node ShiningRay ShanghaiRuby vs Node ShiningRay Shanghai
Ruby vs Node ShiningRay ShanghaiJackson Tian
 
Gatling - Bordeaux JUG
Gatling - Bordeaux JUGGatling - Bordeaux JUG
Gatling - Bordeaux JUGslandelle
 
How to meets Async and Task
How to meets Async and TaskHow to meets Async and Task
How to meets Async and TaskKouji Matsui
 
Andrii Shumada "No excuses for not writing tests"
Andrii Shumada "No excuses for not writing tests"Andrii Shumada "No excuses for not writing tests"
Andrii Shumada "No excuses for not writing tests"Fwdays
 
Meetup React Sanca - 29/11/18 - React Testing
Meetup React Sanca - 29/11/18 - React TestingMeetup React Sanca - 29/11/18 - React Testing
Meetup React Sanca - 29/11/18 - React TestingAugusto Lazaro
 
Gestión de infraestructura tomcat tom ee con tfactory
Gestión de infraestructura tomcat tom ee con tfactoryGestión de infraestructura tomcat tom ee con tfactory
Gestión de infraestructura tomcat tom ee con tfactoryCésar Hernández
 
Gatling Tool in Action at Devoxx 2012
Gatling Tool in Action at Devoxx 2012Gatling Tool in Action at Devoxx 2012
Gatling Tool in Action at Devoxx 2012slandelle
 
Testing of React JS app
Testing of React JS appTesting of React JS app
Testing of React JS appAleks Zinevych
 
All of the thing about Postman
All of the thing about PostmanAll of the thing about Postman
All of the thing about PostmanAlihossein shahabi
 
JSUG - QTJambi by Jan Zarnikov
JSUG - QTJambi by Jan ZarnikovJSUG - QTJambi by Jan Zarnikov
JSUG - QTJambi by Jan ZarnikovChristoph Pickl
 

Tendances (20)

Java concurrency
Java concurrencyJava concurrency
Java concurrency
 
Making react more like rails
Making react more like railsMaking react more like rails
Making react more like rails
 
MyCPAN ( LA.pm, September 2007 )
MyCPAN ( LA.pm, September 2007 )MyCPAN ( LA.pm, September 2007 )
MyCPAN ( LA.pm, September 2007 )
 
PPW2007 - Continuity Project
PPW2007 - Continuity ProjectPPW2007 - Continuity Project
PPW2007 - Continuity Project
 
Capistrano @ VilniusPHP
Capistrano @ VilniusPHPCapistrano @ VilniusPHP
Capistrano @ VilniusPHP
 
Grape golilath
Grape golilathGrape golilath
Grape golilath
 
Ruby vs Node ShiningRay Shanghai
Ruby vs Node ShiningRay ShanghaiRuby vs Node ShiningRay Shanghai
Ruby vs Node ShiningRay Shanghai
 
Gatling - Bordeaux JUG
Gatling - Bordeaux JUGGatling - Bordeaux JUG
Gatling - Bordeaux JUG
 
How to meets Async and Task
How to meets Async and TaskHow to meets Async and Task
How to meets Async and Task
 
Andrii Shumada "No excuses for not writing tests"
Andrii Shumada "No excuses for not writing tests"Andrii Shumada "No excuses for not writing tests"
Andrii Shumada "No excuses for not writing tests"
 
Concurrency in ruby
Concurrency in rubyConcurrency in ruby
Concurrency in ruby
 
Meetup React Sanca - 29/11/18 - React Testing
Meetup React Sanca - 29/11/18 - React TestingMeetup React Sanca - 29/11/18 - React Testing
Meetup React Sanca - 29/11/18 - React Testing
 
Event Machine
Event MachineEvent Machine
Event Machine
 
Gestión de infraestructura tomcat tom ee con tfactory
Gestión de infraestructura tomcat tom ee con tfactoryGestión de infraestructura tomcat tom ee con tfactory
Gestión de infraestructura tomcat tom ee con tfactory
 
Gatling Tool in Action at Devoxx 2012
Gatling Tool in Action at Devoxx 2012Gatling Tool in Action at Devoxx 2012
Gatling Tool in Action at Devoxx 2012
 
Testing of React JS app
Testing of React JS appTesting of React JS app
Testing of React JS app
 
Daniel Sloof: Magento on HHVM
Daniel Sloof: Magento on HHVMDaniel Sloof: Magento on HHVM
Daniel Sloof: Magento on HHVM
 
Whats next in clientside templating
Whats next in clientside templatingWhats next in clientside templating
Whats next in clientside templating
 
All of the thing about Postman
All of the thing about PostmanAll of the thing about Postman
All of the thing about Postman
 
JSUG - QTJambi by Jan Zarnikov
JSUG - QTJambi by Jan ZarnikovJSUG - QTJambi by Jan Zarnikov
JSUG - QTJambi by Jan Zarnikov
 

Similaire à Java concurrency API introduction focusing on ExecutorService

Concurrent Programming in Java
Concurrent Programming in JavaConcurrent Programming in Java
Concurrent Programming in JavaRuben Inoto Soto
 
Concurrency with side-effects – cats way
Concurrency with side-effects – cats wayConcurrency with side-effects – cats way
Concurrency with side-effects – cats waystasimus
 
Java Course 15: Ant, Scripting, Spring, Hibernate
Java Course 15: Ant, Scripting, Spring, HibernateJava Course 15: Ant, Scripting, Spring, Hibernate
Java Course 15: Ant, Scripting, Spring, HibernateAnton Keks
 
NovaProva, a new generation unit test framework for C programs
NovaProva, a new generation unit test framework for C programsNovaProva, a new generation unit test framework for C programs
NovaProva, a new generation unit test framework for C programsGreg Banks
 
Maximizing Throughput and Reliability with Pipelined Tasks
Maximizing Throughput and Reliability with Pipelined TasksMaximizing Throughput and Reliability with Pipelined Tasks
Maximizing Throughput and Reliability with Pipelined TasksPhillip Koza
 
Java Course 6: Introduction to Agile
Java Course 6: Introduction to AgileJava Course 6: Introduction to Agile
Java Course 6: Introduction to AgileAnton Keks
 
Programming with Threads in Java
Programming with Threads in JavaProgramming with Threads in Java
Programming with Threads in Javakoji lin
 
Get ready for FRC 2015: Intro to Java 5 through 8 updates and Eclipse
Get ready for FRC 2015: Intro to Java 5 through 8 updates and EclipseGet ready for FRC 2015: Intro to Java 5 through 8 updates and Eclipse
Get ready for FRC 2015: Intro to Java 5 through 8 updates and EclipseJeanne Boyarsky
 
MERIMeeting du 27 mai 2014 - Parallel Programming
MERIMeeting du 27 mai 2014 - Parallel ProgrammingMERIMeeting du 27 mai 2014 - Parallel Programming
MERIMeeting du 27 mai 2014 - Parallel ProgrammingOlivier NAVARRE
 
Java ppts unit1
Java ppts unit1Java ppts unit1
Java ppts unit1Priya11Tcs
 
Ten Man-Years of JavaFX: Real World Project Experiences
Ten Man-Years of JavaFX: Real World Project ExperiencesTen Man-Years of JavaFX: Real World Project Experiences
Ten Man-Years of JavaFX: Real World Project ExperiencesHenrik Olsson
 
Looming Marvelous - Virtual Threads in Java Javaland.pdf
Looming Marvelous - Virtual Threads in Java Javaland.pdfLooming Marvelous - Virtual Threads in Java Javaland.pdf
Looming Marvelous - Virtual Threads in Java Javaland.pdfjexp
 
212 kuliah 01 pengenalan pemrograman berorientasi objek (java)
212 kuliah 01   pengenalan pemrograman berorientasi objek (java)212 kuliah 01   pengenalan pemrograman berorientasi objek (java)
212 kuliah 01 pengenalan pemrograman berorientasi objek (java)yuan99
 
Codeception: introduction to php testing (v2 - Aberdeen php)
Codeception: introduction to php testing (v2 - Aberdeen php)Codeception: introduction to php testing (v2 - Aberdeen php)
Codeception: introduction to php testing (v2 - Aberdeen php)Engineor
 
[HKOSCON][20190615][DevOps with Ansible, From Native to Kubernetes]
[HKOSCON][20190615][DevOps with Ansible, From Native to Kubernetes][HKOSCON][20190615][DevOps with Ansible, From Native to Kubernetes]
[HKOSCON][20190615][DevOps with Ansible, From Native to Kubernetes]Wong Hoi Sing Edison
 
Continuous testing and deployment in Perl (London.pm Technical Meeting Octobe...
Continuous testing and deployment in Perl (London.pm Technical Meeting Octobe...Continuous testing and deployment in Perl (London.pm Technical Meeting Octobe...
Continuous testing and deployment in Perl (London.pm Technical Meeting Octobe...Alex Balhatchet
 
[HKOSCON][20200613][ Ansible: From VM to Kubernetes]
[HKOSCON][20200613][ Ansible: From VM to Kubernetes][HKOSCON][20200613][ Ansible: From VM to Kubernetes]
[HKOSCON][20200613][ Ansible: From VM to Kubernetes]Wong Hoi Sing Edison
 
Property-based testing an open-source compiler, pflua (FOSDEM 2015)
Property-based testing an open-source compiler, pflua (FOSDEM 2015)Property-based testing an open-source compiler, pflua (FOSDEM 2015)
Property-based testing an open-source compiler, pflua (FOSDEM 2015)Igalia
 
Codeception: introduction to php testing
Codeception: introduction to php testingCodeception: introduction to php testing
Codeception: introduction to php testingEngineor
 

Similaire à Java concurrency API introduction focusing on ExecutorService (20)

Concurrent Programming in Java
Concurrent Programming in JavaConcurrent Programming in Java
Concurrent Programming in Java
 
Concurrency with side-effects – cats way
Concurrency with side-effects – cats wayConcurrency with side-effects – cats way
Concurrency with side-effects – cats way
 
Java Course 15: Ant, Scripting, Spring, Hibernate
Java Course 15: Ant, Scripting, Spring, HibernateJava Course 15: Ant, Scripting, Spring, Hibernate
Java Course 15: Ant, Scripting, Spring, Hibernate
 
NovaProva, a new generation unit test framework for C programs
NovaProva, a new generation unit test framework for C programsNovaProva, a new generation unit test framework for C programs
NovaProva, a new generation unit test framework for C programs
 
Maximizing Throughput and Reliability with Pipelined Tasks
Maximizing Throughput and Reliability with Pipelined TasksMaximizing Throughput and Reliability with Pipelined Tasks
Maximizing Throughput and Reliability with Pipelined Tasks
 
Java Course 6: Introduction to Agile
Java Course 6: Introduction to AgileJava Course 6: Introduction to Agile
Java Course 6: Introduction to Agile
 
Programming with Threads in Java
Programming with Threads in JavaProgramming with Threads in Java
Programming with Threads in Java
 
Java multi thread programming on cmp system
Java multi thread programming on cmp systemJava multi thread programming on cmp system
Java multi thread programming on cmp system
 
Get ready for FRC 2015: Intro to Java 5 through 8 updates and Eclipse
Get ready for FRC 2015: Intro to Java 5 through 8 updates and EclipseGet ready for FRC 2015: Intro to Java 5 through 8 updates and Eclipse
Get ready for FRC 2015: Intro to Java 5 through 8 updates and Eclipse
 
MERIMeeting du 27 mai 2014 - Parallel Programming
MERIMeeting du 27 mai 2014 - Parallel ProgrammingMERIMeeting du 27 mai 2014 - Parallel Programming
MERIMeeting du 27 mai 2014 - Parallel Programming
 
Java ppts unit1
Java ppts unit1Java ppts unit1
Java ppts unit1
 
Ten Man-Years of JavaFX: Real World Project Experiences
Ten Man-Years of JavaFX: Real World Project ExperiencesTen Man-Years of JavaFX: Real World Project Experiences
Ten Man-Years of JavaFX: Real World Project Experiences
 
Looming Marvelous - Virtual Threads in Java Javaland.pdf
Looming Marvelous - Virtual Threads in Java Javaland.pdfLooming Marvelous - Virtual Threads in Java Javaland.pdf
Looming Marvelous - Virtual Threads in Java Javaland.pdf
 
212 kuliah 01 pengenalan pemrograman berorientasi objek (java)
212 kuliah 01   pengenalan pemrograman berorientasi objek (java)212 kuliah 01   pengenalan pemrograman berorientasi objek (java)
212 kuliah 01 pengenalan pemrograman berorientasi objek (java)
 
Codeception: introduction to php testing (v2 - Aberdeen php)
Codeception: introduction to php testing (v2 - Aberdeen php)Codeception: introduction to php testing (v2 - Aberdeen php)
Codeception: introduction to php testing (v2 - Aberdeen php)
 
[HKOSCON][20190615][DevOps with Ansible, From Native to Kubernetes]
[HKOSCON][20190615][DevOps with Ansible, From Native to Kubernetes][HKOSCON][20190615][DevOps with Ansible, From Native to Kubernetes]
[HKOSCON][20190615][DevOps with Ansible, From Native to Kubernetes]
 
Continuous testing and deployment in Perl (London.pm Technical Meeting Octobe...
Continuous testing and deployment in Perl (London.pm Technical Meeting Octobe...Continuous testing and deployment in Perl (London.pm Technical Meeting Octobe...
Continuous testing and deployment in Perl (London.pm Technical Meeting Octobe...
 
[HKOSCON][20200613][ Ansible: From VM to Kubernetes]
[HKOSCON][20200613][ Ansible: From VM to Kubernetes][HKOSCON][20200613][ Ansible: From VM to Kubernetes]
[HKOSCON][20200613][ Ansible: From VM to Kubernetes]
 
Property-based testing an open-source compiler, pflua (FOSDEM 2015)
Property-based testing an open-source compiler, pflua (FOSDEM 2015)Property-based testing an open-source compiler, pflua (FOSDEM 2015)
Property-based testing an open-source compiler, pflua (FOSDEM 2015)
 
Codeception: introduction to php testing
Codeception: introduction to php testingCodeception: introduction to php testing
Codeception: introduction to php testing
 

Plus de fbenault

Property based-testing
Property based-testingProperty based-testing
Property based-testingfbenault
 
Assertj-DB
Assertj-DBAssertj-DB
Assertj-DBfbenault
 
Introduction to the language R
Introduction to the language RIntroduction to the language R
Introduction to the language Rfbenault
 
Assertj-core
Assertj-coreAssertj-core
Assertj-corefbenault
 
System rules
System rulesSystem rules
System rulesfbenault
 
Db in-memory
Db in-memoryDb in-memory
Db in-memoryfbenault
 

Plus de fbenault (13)

Bdd java
Bdd javaBdd java
Bdd java
 
Property based-testing
Property based-testingProperty based-testing
Property based-testing
 
Test ng
Test ngTest ng
Test ng
 
Assertj-DB
Assertj-DBAssertj-DB
Assertj-DB
 
Introduction to the language R
Introduction to the language RIntroduction to the language R
Introduction to the language R
 
Assertj-core
Assertj-coreAssertj-core
Assertj-core
 
Junit
JunitJunit
Junit
 
System rules
System rulesSystem rules
System rules
 
Db in-memory
Db in-memoryDb in-memory
Db in-memory
 
DbSetup
DbSetupDbSetup
DbSetup
 
Guava
GuavaGuava
Guava
 
Java8
Java8Java8
Java8
 
Easymock
EasymockEasymock
Easymock
 

Dernier

Contact Rya Baby for Call Girls New Delhi
Contact Rya Baby for Call Girls New DelhiContact Rya Baby for Call Girls New Delhi
Contact Rya Baby for Call Girls New Delhimiss dipika
 
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一z xss
 
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作ys8omjxb
 
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170Sonam Pathan
 
PHP-based rendering of TYPO3 Documentation
PHP-based rendering of TYPO3 DocumentationPHP-based rendering of TYPO3 Documentation
PHP-based rendering of TYPO3 DocumentationLinaWolf1
 
SCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is prediSCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is predieusebiomeyer
 
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书rnrncn29
 
Film cover research (1).pptxsdasdasdasdasdasa
Film cover research (1).pptxsdasdasdasdasdasaFilm cover research (1).pptxsdasdasdasdasdasa
Film cover research (1).pptxsdasdasdasdasdasa494f574xmv
 
Top 10 Interactive Website Design Trends in 2024.pptx
Top 10 Interactive Website Design Trends in 2024.pptxTop 10 Interactive Website Design Trends in 2024.pptx
Top 10 Interactive Website Design Trends in 2024.pptxDyna Gilbert
 
Call Girls Near The Suryaa Hotel New Delhi 9873777170
Call Girls Near The Suryaa Hotel New Delhi 9873777170Call Girls Near The Suryaa Hotel New Delhi 9873777170
Call Girls Near The Suryaa Hotel New Delhi 9873777170Sonam Pathan
 
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书zdzoqco
 
Font Performance - NYC WebPerf Meetup April '24
Font Performance - NYC WebPerf Meetup April '24Font Performance - NYC WebPerf Meetup April '24
Font Performance - NYC WebPerf Meetup April '24Paul Calvano
 
NSX-T and Service Interfaces presentation
NSX-T and Service Interfaces presentationNSX-T and Service Interfaces presentation
NSX-T and Service Interfaces presentationMarko4394
 
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书rnrncn29
 
Q4-1-Illustrating-Hypothesis-Testing.pptx
Q4-1-Illustrating-Hypothesis-Testing.pptxQ4-1-Illustrating-Hypothesis-Testing.pptx
Q4-1-Illustrating-Hypothesis-Testing.pptxeditsforyah
 

Dernier (17)

Contact Rya Baby for Call Girls New Delhi
Contact Rya Baby for Call Girls New DelhiContact Rya Baby for Call Girls New Delhi
Contact Rya Baby for Call Girls New Delhi
 
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一
 
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作
 
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170
 
PHP-based rendering of TYPO3 Documentation
PHP-based rendering of TYPO3 DocumentationPHP-based rendering of TYPO3 Documentation
PHP-based rendering of TYPO3 Documentation
 
young call girls in Uttam Nagar🔝 9953056974 🔝 Delhi escort Service
young call girls in Uttam Nagar🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Uttam Nagar🔝 9953056974 🔝 Delhi escort Service
young call girls in Uttam Nagar🔝 9953056974 🔝 Delhi escort Service
 
SCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is prediSCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is predi
 
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
 
Film cover research (1).pptxsdasdasdasdasdasa
Film cover research (1).pptxsdasdasdasdasdasaFilm cover research (1).pptxsdasdasdasdasdasa
Film cover research (1).pptxsdasdasdasdasdasa
 
Top 10 Interactive Website Design Trends in 2024.pptx
Top 10 Interactive Website Design Trends in 2024.pptxTop 10 Interactive Website Design Trends in 2024.pptx
Top 10 Interactive Website Design Trends in 2024.pptx
 
Call Girls Near The Suryaa Hotel New Delhi 9873777170
Call Girls Near The Suryaa Hotel New Delhi 9873777170Call Girls Near The Suryaa Hotel New Delhi 9873777170
Call Girls Near The Suryaa Hotel New Delhi 9873777170
 
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书
 
Hot Sexy call girls in Rk Puram 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in  Rk Puram 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in  Rk Puram 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Rk Puram 🔝 9953056974 🔝 Delhi escort Service
 
Font Performance - NYC WebPerf Meetup April '24
Font Performance - NYC WebPerf Meetup April '24Font Performance - NYC WebPerf Meetup April '24
Font Performance - NYC WebPerf Meetup April '24
 
NSX-T and Service Interfaces presentation
NSX-T and Service Interfaces presentationNSX-T and Service Interfaces presentation
NSX-T and Service Interfaces presentation
 
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
 
Q4-1-Illustrating-Hypothesis-Testing.pptx
Q4-1-Illustrating-Hypothesis-Testing.pptxQ4-1-Illustrating-Hypothesis-Testing.pptx
Q4-1-Illustrating-Hypothesis-Testing.pptx
 

Java concurrency API introduction focusing on ExecutorService

  • 1. Java concurrency API By Franck Benault Created 06/12/2015 Last update 22/11/2015
  • 2. Java concurrency introduction ● Parallelism can speed up you program – But is Java the best language for concurrency ?
  • 3. Java concurrency links ● My examples in Github – https://github.com/franck-benault/test-concurrence
  • 5. Goal of this presentation ● Goal – Very simple presentation ● Focus on ExecutorService
  • 6. Java concurrency : Basics threads ● Principle – Class Worker implemented Runnable interface – Worker w = new Worker(...) ; – Thread t = new Thread(w) ; – t.start() ; – t.join() ; //wait until the end of the thread ● Problems – Run() method does not return any information (return value, exception) – How to manage a pool of threads ? – Do not use this way anymore !
  • 7. Java concurrency : Sleep ● Old way – Thread.sleep(100); ● Since Java5 – TimeUnit.MILLISECONDS.sleep(100);
  • 8. Java concurrency : show threads with jvisualVM
  • 9. Java concurrency : Basics isSynchronized ● Key word – On a bloc (with a parameter) – On a method ● Thread safe
  • 10. Java concurrency : ExcecutorService ● Management of a pool of threads ● Accept Callable and Runnable ExecutorService executor; executor = Executors.newFixedThreadPool(threadPoolSize); WorkerThread workerThread = new WorkerThread(...); executor.submit(workerThread); ... executor.shutdown(); while (!executor.isTerminated()) Thread.sleep(10);
  • 11. Conclusion ● Let's start with concurrency in Java