Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
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
180
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
48
Your Java isn't the same
graciano
0
240
Cloud Batch
graciano
0
210
Batch Processing
graciano
0
460
Java 9 ao 17 - Oracle no TDC
graciano
0
150
KnoxJava - Java 9-17
graciano
0
190
Java 9 to Java 16: A review of recent changes to the language
graciano
0
200
Java 9 ao 15 - Evolução da Linguagem Java
graciano
0
300
Other Decks in Technology
See All in Technology
自主式軟體工廠
philipz
0
260
hackers_champloo_2026_tidb
makocchi
0
140
WasmをRustにする
sansantech
PRO
0
180
AIカンパニーへの転換を支えた、エンジニアの仕事の再定義
kworkdev
PRO
1
430
自分で立ててみるLLMサービス
y_sera15
0
160
V8のArray.prototype.flatを最大約20倍速くするまでと、巨大OSSへの大規模コミットの道のり
riyaamemiya
0
270
Jetson Orin Nanoとk3sとローカルLLMで音声文字起こしシステム作ってみた
y_sera15
0
120
DWH の限界突破! AI エージェント向け爆速リアルタイムデータ基盤 ClickHouse
jozono
1
390
おそらく日本で唯一のDevRelインターン生として
husengs7
0
170
【Data Engineering Summit2026_登壇資料】医療ビッグデータ×AIエージェントを支えるデータ基盤とハーネスエンジニアリング
jmdc_presentation
0
130
QA4AI 2026-Oct 生成AI時代の品質保証
tokuty
0
360
パッチ更新でterraform initが落ちた日
grimoh
1
120
Featured
See All Featured
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.6k
What's in a price? How to price your products and services
michaelherold
247
13k
The Art of Programming - Codeland 2020
erikaheidi
57
14k
Joys of Absence: A Defence of Solitary Play
codingconduct
1
540
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.5k
Between Models and Reality
mayunak
4
490
Fantastic passwords and where to find them - at NoRuKo
philnash
53
4k
Build your cross-platform service in a week with App Engine
jlugia
234
19k
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
330
Automating Front-end Workflow
addyosmani
1369
210k
Intergalactic Javascript Robots from Outer Space
tanoku
273
27k
KATA
mclloyd
PRO
35
16k
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()
• • • •