Lock in $30 Savings on PRO—Offer Ends Soon! ⏳
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
130
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
25
Your Java isn't the same
graciano
0
210
Cloud Batch
graciano
0
160
Batch Processing
graciano
0
390
Java 9 ao 17 - Oracle no TDC
graciano
0
120
KnoxJava - Java 9-17
graciano
0
160
Java 9 to Java 16: A review of recent changes to the language
graciano
0
150
Java 9 ao 15 - Evolução da Linguagem Java
graciano
0
270
Other Decks in Technology
See All in Technology
Lambdaの常識はどう変わる?!re:Invent 2025 before after
iwatatomoya
1
370
生成AI時代の自動E2Eテスト運用とPlaywright実践知_引持力哉
legalontechnologies
PRO
0
210
意外とあった SQL Server 関連アップデート + Database Savings Plans
stknohg
PRO
0
290
AIと二人三脚で育てた、個人開発アプリグロース術
zozotech
PRO
0
690
AWS CLIの新しい認証情報設定方法aws loginコマンドの実態
wkm2
5
600
大企業でもできる!ボトムアップで拡大させるプラットフォームの作り方
findy_eventslides
1
600
AI駆動開発における設計思想 認知負荷を下げるフロントエンドアーキテクチャ/ 20251211 Teppei Hanai
shift_evolve
PRO
2
190
AWSセキュリティアップデートとAWSを育てる話
cmusudakeisuke
0
100
エンジニアリングをやめたくないので問い続ける
estie
0
150
Playwright x GitHub Actionsで実現する「レビューしやすい」E2Eテストレポート
kinosuke01
0
450
計算機科学をRubyと歩む 〜DFA型正規表現エンジンをつくる~
ydah
3
210
学習データって増やせばいいんですか?
ftakahashi
1
270
Featured
See All Featured
Thoughts on Productivity
jonyablonski
73
5k
Fireside Chat
paigeccino
41
3.7k
How STYLIGHT went responsive
nonsquared
100
6k
Rebuilding a faster, lazier Slack
samanthasiow
84
9.3k
The Pragmatic Product Professional
lauravandoore
37
7.1k
Visualization
eitanlees
150
16k
Making the Leap to Tech Lead
cromwellryan
135
9.7k
What's in a price? How to price your products and services
michaelherold
246
12k
The Power of CSS Pseudo Elements
geoffreycrofte
80
6.1k
Designing for Performance
lara
610
69k
Large-scale JavaScript Application Architecture
addyosmani
515
110k
YesSQL, Process and Tooling at Scale
rocio
174
15k
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()
• • • •