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
150
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
Advancing with Java
graciano
0
22
Your Java isn't the same
graciano
0
220
Cloud Batch
graciano
0
180
Batch Processing
graciano
0
410
Java 9 ao 17 - Oracle no TDC
graciano
0
130
KnoxJava - Java 9-17
graciano
0
170
Java 9 to Java 16: A review of recent changes to the language
graciano
0
160
Java 9 ao 15 - Evolução da Linguagem Java
graciano
0
290
Other Decks in Technology
See All in Technology
GitHub Copilot CLI で Azure Portal to Bicep
tsubakimoto_s
0
160
Astro Islandsの 内部実装を 「日本で一番わかりやすく」 ざっくり解説!
knj
0
150
プラットフォームエンジニアリングはAI時代の開発者をどう救うのか
jacopen
8
4.2k
Phase10_組織浸透_データ活用
overflowinc
0
800
モジュラモノリス導入から4年間の総括:アーキテクチャと組織の相互作用について / Architecture and Organizational Interaction
nazonohito51
3
1.3k
TypeScript 7.0の現在地と備え方
uhyo
7
2k
形式手法特論:SMT ソルバで解く認可ポリシの静的解析 #kernelvm / Kernel VM Study Tsukuba No3
ytaka23
1
720
既存アプリの延命も,最新技術での新規開発も:WebSphereの最新情報
ktgrryt
0
110
"作る"から"使われる"へ:Backstage 活用の現在地
sbtechnight
0
230
Bill One 開発エンジニア 紹介資料
sansan33
PRO
5
18k
新規事業×QAの挑戦:不確実性を乗りこなす!フェーズごとに求められるQAの役割変革
hacomono
PRO
0
150
AlloyDB 奮闘記
hatappi
0
190
Featured
See All Featured
Believing is Seeing
oripsolob
1
90
Speed Design
sergeychernyshev
33
1.6k
Making the Leap to Tech Lead
cromwellryan
135
9.8k
Un-Boring Meetings
codingconduct
0
230
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
Mozcon NYC 2025: Stop Losing SEO Traffic
samtorres
0
180
A Tale of Four Properties
chriscoyier
163
24k
Winning Ecommerce Organic Search in an AI Era - #searchnstuff2025
aleyda
1
1.9k
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
130
Ethics towards AI in product and experience design
skipperchong
2
230
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
5
770
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
230
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()
• • • •