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
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Rodrigo Graciano
January 16, 2021
Technology
160
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
36
Your Java isn't the same
graciano
0
240
Cloud Batch
graciano
0
200
Batch Processing
graciano
0
430
Java 9 ao 17 - Oracle no TDC
graciano
0
150
KnoxJava - Java 9-17
graciano
0
180
Java 9 to Java 16: A review of recent changes to the language
graciano
0
180
Java 9 ao 15 - Evolução da Linguagem Java
graciano
0
300
Other Decks in Technology
See All in Technology
20260608_Codexの可能性_ノンプログラマー向け_大城追記
doradora09
PRO
0
760
攻撃と防御で学ぶAI時代のプロダクトセキュリティ演習
recruitengineers
PRO
1
450
【CEDEC2026】専門性の高いデフォルメチームが挑んだ人材育成戦略 〜Cygames Academiaの企画から実施まで〜
cygames
PRO
0
490
【CEDEC2026】『Relink』を拡張せよ - 『GRANBLUE FANTASY: Relink - Endless Ragnarok』の開発速度と品質を守るCI運用
cygames
PRO
0
130
toio・myCobotでフィジカルAIっぽいことを行うための検討(とりあえず調査) / フィジカルAI LT(IoTLTによる開催)
you
PRO
0
290
研究開発部の紹介 / Sansan R&D Profile
sansan33
PRO
4
24k
【Google Cloud Next Tokyo'26】Gemini Enterprise と Oracle AI Database で実現する、業務データ活用を実現する AI エージェント実装
shisyu_gaku
0
210
老害フォレンジッカーはAI羊の夢を見るか?
tadmaddad
0
150
侵入は突然に 〜 IoTマルウェアと悪用される家庭の機器 ~ / When Intrusion Strikes: IoT Malware and the Abuse of Home Devices
nttcom
0
1.5k
もう一度考える SRE チームの作り方・育て方 / Rethinking SRE #1: Building and Growing SRE Teams
rrreeeyyy
6
990
AIは実装を速くする。では、私たちは何を今作るべきか?-立場を越えてリリースに向き合ったチーム開発の実践 / 20260801 Hiromi Nakaya and Naoki Takahashi
shift_evolve
PRO
3
400
Redmine 7.0 新機能・機能強化解説(OSC2026京都ダイジェスト版)
vividtone
1
190
Featured
See All Featured
Art, The Web, and Tiny UX
lynnandtonic
304
22k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8.3k
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
230
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
330
The Invisible Side of Design
smashingmag
301
52k
SEO Brein meetup: CTRL+C is not how to scale international SEO
lindahogenes
1
2.8k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
2.9k
The Art of Programming - Codeland 2020
erikaheidi
57
14k
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
1
460
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
230
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
200
Large-scale JavaScript Application Architecture
addyosmani
515
110k
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()
• • • •