Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Of concurrency and other demons
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Rodrigo Graciano
January 16, 2021
Technology
0
140
Of concurrency and other demons
Talk about concurrency.
Initially presented at DawsCon with Hillmer Chona
Rodrigo Graciano
January 16, 2021
Tweet
Share
More Decks by Rodrigo Graciano
See All by Rodrigo Graciano
Beyond Coding
graciano
0
35
Your Java isn't the same
graciano
0
220
Cloud Batch
graciano
0
170
Batch Processing
graciano
0
400
Java 9 ao 17 - Oracle no TDC
graciano
0
130
KnoxJava - Java 9-17
graciano
0
170
Java 9 to Java 16: A review of recent changes to the language
graciano
0
160
Java 9 ao 15 - Evolução da Linguagem Java
graciano
0
290
Other Decks in Technology
See All in Technology
20260204_Midosuji_Tech
takuyay0ne
1
180
Agent Skils
dip_tech
PRO
0
170
22nd ACRi Webinar - NTT Kawahara-san's slide
nao_sumikawa
0
130
StrandsとNeptuneを使ってナレッジグラフを構築する
yakumo
1
150
登壇駆動学習のすすめ — CfPのネタの見つけ方と書くときに意識していること
bicstone
3
200
Azure Copilot Migration Agent / #jazug
koudaiii
1
160
Exadata Fleet Update
oracle4engineer
PRO
0
1.2k
AWS Network Firewall Proxyを触ってみた
nagisa53
1
260
#23 Turing × atmaCup 2nd 6th Place Solution + 取り組み方紹介
yumizu
0
140
LiDARが変えたARの"距離感"
zozotech
PRO
0
220
新規事業開発でのAWS活用
amixedcolor
1
160
生成AIで始める業務改革 - 製造業編 in 福島 -
daikikanemitsu
2
550
Featured
See All Featured
What’s in a name? Adding method to the madness
productmarketing
PRO
24
3.9k
Odyssey Design
rkendrick25
PRO
1
510
Docker and Python
trallard
47
3.7k
Bash Introduction
62gerente
615
210k
VelocityConf: Rendering Performance Case Studies
addyosmani
333
24k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.1k
Marketing to machines
jonoalderson
1
4.9k
How STYLIGHT went responsive
nonsquared
100
6k
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
120
Fireside Chat
paigeccino
41
3.8k
Imperfection Machines: The Place of Print at Facebook
scottboms
269
14k
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
0
420
Transcript
None
➔ Software developer - Team lead ➔ Java Champion ➔
Medellin Java Users Group Leader ➔ hibernate/hibernate-validator Contributor ➔ Duke’s Choice Award Winner ➔ Eclipse Collections contributor
➔ Professional with 10+ years ➔ Principal Software Engineer -
NY ➔ NYJavaSIG Leader ➔ graciano.dev ➔ Twitter: @rodrigograciano
• • • •
• Concurrency when we have many task, largely independent, and
we use the same resource to do them at a time • Parallelism is when we want to do one task, and we split up in multiple subtasks
A Thread is an independent path of execution that allows
a program to operate more efficiently by doing multiple things at the same time. Threads can be used to perform complicated tasks in the background without interrupting the main program.
• Synchronous: when we wait to finish a task before
moving to the next one • Asynchronous: when we move to another task before it finishes
• Thread t = new Thread( ()-> this.doSomething( thing ));
t.start(); • ExecutorService executor = Executors.newFixedThreadPool( 10 ); Future<?> future = executor.submit( ()-> this.doSomething( thing )); • CompletableFuture.runAsync( ()-> this.doSomething( thing )); • Thread.builder().virtual().name("name").task(() -> this.doSomething( thing )).start();
None
None
Stream API CompletableFuture Creation Chained operations Return forEach runAsync thenAccept
/ thenRun void map supplyAsync thenApply CompletableFuture<U>
None
CompletableFuture<Void>::runAsync (Runnable runnable) <U> CompletableFuture<U>::supplyAsync (Supplier<U> supplier) CompletableFuture<Void>::runAsync (Runnable runnable,
Executor executor) <U> CompletableFuture<U>::supplyAsync (Supplier<U> supplier, Executor executor)
static ExecutorService newCachedThreadPool() static ExecutorService newFixedThreadPool (int nThreads) static ScheduledExecutorService
newScheduledThreadPool (int corePoolSize) static ExecutorService newSingleThreadExecutor() static ScheduledExecutorService newSingleThreadScheduledExecutor() static ExecutorService newWorkStealingPool()
T::get () throws InterruptedException , ExecutionException T::get (long timeout, TimeUnit
unit) throws InterruptedException , ExecutionException , TimeoutException T::getNow (T valueIfAbsent) T::join()
• • • •