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
120
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
13
Your Java isn't the same
graciano
0
200
Cloud Batch
graciano
0
160
Batch Processing
graciano
0
370
Java 9 ao 17 - Oracle no TDC
graciano
0
110
KnoxJava - Java 9-17
graciano
0
160
Java 9 to Java 16: A review of recent changes to the language
graciano
0
140
Java 9 ao 15 - Evolução da Linguagem Java
graciano
0
260
Other Decks in Technology
See All in Technology
許しとアジャイル
jnuank
1
120
OCI Network Firewall 概要
oracle4engineer
PRO
1
7.8k
Why Governance Matters: The Key to Reducing Risk Without Slowing Down
sarahjwells
0
110
[2025-09-30] Databricks Genie を利用した分析基盤とデータモデリングの IVRy の現在地
wxyzzz
0
470
業務自動化プラットフォーム Google Agentspace に入門してみる #devio2025
maroon1st
0
190
KAGのLT会 #8 - 東京リージョンでGAしたAmazon Q in QuickSightを使って、報告用の資料を作ってみた
0air
0
200
OpenAI gpt-oss ファインチューニング入門
kmotohas
2
960
AWSにおけるTrend Vision Oneの効果について
shimak
0
130
Flaky Testへの現実解をGoのプロポーザルから考える | Go Conference 2025
upamune
1
420
PLaMo2シリーズのvLLM実装 / PFN LLM セミナー
pfn
PRO
2
980
ACA でMAGI システムを社内で展開しようとした話
mappie_kochi
1
260
KMP の Swift export
kokihirokawa
0
330
Featured
See All Featured
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
358
30k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
15
1.7k
Visualization
eitanlees
148
16k
What's in a price? How to price your products and services
michaelherold
246
12k
Testing 201, or: Great Expectations
jmmastey
45
7.7k
Balancing Empowerment & Direction
lara
4
680
Unsuck your backbone
ammeep
671
58k
Code Reviewing Like a Champion
maltzj
525
40k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
45
2.5k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
114
20k
The Cost Of JavaScript in 2023
addyosmani
53
9k
GitHub's CSS Performance
jonrohan
1032
460k
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()
• • • •