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
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
35
Your Java isn't the same
graciano
0
230
Cloud Batch
graciano
0
200
Batch Processing
graciano
0
430
Java 9 ao 17 - Oracle no TDC
graciano
0
140
KnoxJava - Java 9-17
graciano
0
170
Java 9 to Java 16: A review of recent changes to the language
graciano
0
170
Java 9 ao 15 - Evolução da Linguagem Java
graciano
0
290
Other Decks in Technology
See All in Technology
AAIFに入ってみた ~内から見えるコミュニティ動向~
sato4
0
160
On-behalf-of Token exchange with AgentCore Identity
hironobuiga
2
150
やさしいA2A入門
minorun365
PRO
12
1.7k
現地で盛り上がった WWDC26 Keynote
zozotech
PRO
1
200
新しいVibe Codingと”自走”について
watany
5
290
RSA暗号を手計算したくなること、ありますよね?? (20260615_orestudy6_rsa)
thousanda
0
260
非エンジニアがClaudeと挑んだ「1ヶ月間プロダクト30本ノック」
askokc
0
350
チームで進めるAI駆動アジャイル×ウォーターフォール
kumaiu
0
150
NAB Show 2026 動画技術関連レポート / NAB Show 2026 Report
cyberagentdevelopers
PRO
0
170
ポケモンの型をTypeScriptの型システムで表現してみた
subroh0508
0
370
フロンティアAIのゲート化と地政学リスク
nagatsu
0
130
AI駆動開発を通して感じた、 AI時代のデザイナーの役割変化
whisaiyo
0
260
Featured
See All Featured
How STYLIGHT went responsive
nonsquared
100
6.2k
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
190
The Language of Interfaces
destraynor
162
27k
Six Lessons from altMBA
skipperchong
29
4.3k
The Mindset for Success: Future Career Progression
greggifford
PRO
0
360
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
250
A Tale of Four Properties
chriscoyier
163
24k
HDC tutorial
michielstock
2
700
Game over? The fight for quality and originality in the time of robots
wayneb77
1
200
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
2.9k
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
1
540
AI: The stuff that nobody shows you
jnunemaker
PRO
8
710
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()
• • • •