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
170
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
440
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
AWSとAzureのマルチクラウド活用における強い味方___AWS_Kiroを使った二刀流スキル作成.pdf
duelist2020jp
0
120
:syncing_time:
sksat
2
780
AI駆動開発を組織で促すために
lycorptech_jp
PRO
6
7k
AI時代のデータ基盤を考える問い
pacocat
0
700
サービス内で複数のOP・ASを連鎖させる(OAuth/OIDC Numa (Immersion) Workshop 2026)
oidfj
PRO
0
310
1.5時間を無駄にして学んだwsl2におけるaptとsnapの選択と仕組み
yosaka0123
0
450
【5分でわかる】セーフィー エンジニア向け会社紹介
safie_recruit
0
54k
AIエージェントのためのデータ設計
daiz21
0
410
Introduction to Bill One Development Engineer
sansan33
PRO
0
470
[ホンマでっか SRE] あなたはなぜ SRE に?
_awache
0
270
AIで変わるエンジニアの働き方(仮)
naoinaoi
0
570
EMの役割で 変わったこと・変わらなかったこと
sansantech
PRO
0
140
Featured
See All Featured
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
500
Building a Scalable Design System with Sketch
lauravandoore
463
34k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.3k
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
410
Reflections from 52 weeks, 52 projects
jeffersonlam
356
21k
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
0
490
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.4k
WENDY [Excerpt]
tessaabrams
11
39k
Test your architecture with Archunit
thirion
2
2.4k
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
390
Crafting Experiences
bethany
1
270
Building Flexible Design Systems
yeseniaperezcruz
330
41k
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()
• • • •