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
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Rodrigo Graciano
January 16, 2021
Technology
160
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Of concurrency and other demons
Talk about concurrency.
Initially presented at DawsCon with Hillmer Chona
Rodrigo Graciano
January 16, 2021
More Decks by Rodrigo Graciano
See All by Rodrigo Graciano
Advancing with Java
graciano
0
35
Your Java isn't the same
graciano
0
230
Cloud Batch
graciano
0
200
Batch Processing
graciano
0
430
Java 9 ao 17 - Oracle no TDC
graciano
0
140
KnoxJava - Java 9-17
graciano
0
170
Java 9 to Java 16: A review of recent changes to the language
graciano
0
170
Java 9 ao 15 - Evolução da Linguagem Java
graciano
0
290
Other Decks in Technology
See All in Technology
[AWS Summit Japan 2026]迷っているあなたへ_小さな一歩が、やがて自分を助けてくれる
sh_fk2
2
410
【2026年版】 ベクトル検索とEmbedding最前線
mocobeta
23
7.5k
AIチャット検索改善の3週間
kworkdev
PRO
2
170
AWS Security Hub CSPMの成功・失敗体験
cmusudakeisuke
0
540
技術・能力を向上する原理原則 #きのこセッションa #きのこ2026
bash0c7
0
120
IaC コードを資産へ:AWS CDK 社内ライブラリと横断展開 / aws-summit-japan-2026
gotok365
10
1.6k
Kiro Ambassador を目指す話
k_adachi_01
0
130
Zenoh on Zephyr on LiteX
takasehideki
2
110
ロボティクスの技術 / Robotics Technology
ks91
PRO
0
130
【FinOps】データドリブンな意思決定を目指して
z63d
0
330
4人目のSREはAgent
tanimuyk
0
160
BPaaSで進むAIオペレーションの現在地 AI実装が効く領域とスケーラビリティの選定と実装
kentarofujii
0
180
Featured
See All Featured
4 Signs Your Business is Dying
shpigford
187
22k
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
230
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
6k
A designer walks into a library…
pauljervisheath
211
24k
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
170
Collaborative Software Design: How to facilitate domain modelling decisions
baasie
1
250
Leo the Paperboy
mayatellez
7
1.9k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
3.5k
The Limits of Empathy - UXLibs8
cassininazir
1
370
Raft: Consensus for Rubyists
vanstee
141
7.6k
From π to Pie charts
rasagy
0
220
Evolving SEO for Evolving Search Engines
ryanjones
0
220
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()
• • • •