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
Rodrigo Graciano
January 16, 2021
Technology
0
110
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
Your Java isn't the same
graciano
0
170
Cloud Batch
graciano
0
150
Batch Processing
graciano
0
340
Java 9 ao 17 - Oracle no TDC
graciano
0
100
KnoxJava - Java 9-17
graciano
0
150
Java 9 to Java 16: A review of recent changes to the language
graciano
0
120
Java 9 ao 15 - Evolução da Linguagem Java
graciano
0
250
Other Decks in Technology
See All in Technology
Beyond {shiny}: The Future of Mobile Apps with R
colinfay
1
330
はじめてのSDET / My first challenge as a SDET
bun913
1
190
GitHub MCP Serverを使って Pull Requestを作る、レビューする
hiyokose
2
700
ペアーズにおけるData Catalog導入の取り組み
hisamouna
0
270
ウォンテッドリーにおける Platform Engineering
bgpat
0
180
自分の軸足を見つけろ
tsuemura
2
570
ブラウザのレガシー・独自機能を愛でる-Firefoxの脆弱性4選- / Browser Crash Club #1
masatokinugawa
1
380
近年の PyCon 情勢から見た PyCon APAC のまとめ
terapyon
0
280
テキスト解析で見る PyCon APAC 2025 セッション&スピーカートレンド分析
negi111111
0
270
All You Need Is Kusa 〜Slackデータで始めるデータドリブン〜
jonnojun
0
140
Devinで模索する AIファースト開発〜ゼロベースから始めるDevOpsの進化〜
potix2
PRO
5
2.5k
開発視点でAWS Signerを考えてみよう!! ~コード署名のその先へ~
masakiokuda
3
130
Featured
See All Featured
It's Worth the Effort
3n
184
28k
The Pragmatic Product Professional
lauravandoore
33
6.5k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
356
30k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
49k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
41
2.2k
Imperfection Machines: The Place of Print at Facebook
scottboms
267
13k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
233
17k
A better future with KSS
kneath
239
17k
Become a Pro
speakerdeck
PRO
27
5.3k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
19
1.1k
Speed Design
sergeychernyshev
29
880
For a Future-Friendly Web
brad_frost
176
9.7k
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()
• • • •