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
Vaclav Pech on GPars
Search
Enterprise Java User Group Austria
March 05, 2012
Technology
0
36
Vaclav Pech on GPars
Enterprise Java User Group Austria
March 05, 2012
Tweet
Share
More Decks by Enterprise Java User Group Austria
See All by Enterprise Java User Group Austria
Gerrit Grunwald on What the CRaC... SUPERFAST JVM STARTUP
ejug
2
95
Spring Framework 5.2 - Core Container Revisited
ejug
0
120
Andreas Caternberg on Jenkins Pipelines
ejug
0
540
Martin Ahrer on Continuous Delivery Infrastructure With Docker
ejug
0
120
Dirk Mahler on Software Analyse mit jQAssistant & Neo4j
ejug
1
220
Christoph Strobl on Spring Data & Hypermedia
ejug
0
82
Stefan Armbruster on Graph Modelling Antipatterns
ejug
1
91
Stefan Armbruster on Introduction into Neo4J
ejug
1
76
Michael Nitschinger on Building a reactive Couchbase driver for the JVM
ejug
0
100
Other Decks in Technology
See All in Technology
LINE NEWSにおけるバックエンド開発
lycorptech_jp
PRO
0
240
Windows の新しい管理者保護モード
murachiakira
0
200
生成AI “再”入門 2025年春@WIRED TUESDAY EDITOR'S LOUNGE
kajikent
0
110
(機械学習システムでも) SLO から始める信頼性構築 - ゆる SRE#9 2025/02/21
daigo0927
0
270
データエンジニアリング領域におけるDuckDBのユースケース
chanyou0311
9
2.2k
急成長する企業で作った、エンジニアが輝ける制度/ 20250227 Rinto Ikenoue
shift_evolve
0
130
OPENLOGI Company Profile for engineer
hr01
1
20k
ExaDB-XSで利用されているExadata Exascaleについて
oracle4engineer
PRO
3
250
アジャイルな開発チームでテスト戦略の話は誰がする? / Who Talks About Test Strategy?
ak1210
1
590
Change Managerを活用して本番環境へのセキュアなGUIアクセスを統制する / Control Secure GUI Access to the Production Environment with Change Manager
yuj1osm
0
100
"TEAM"を導入したら最高のエンジニア"Team"を実現できた / Deploying "TEAM" and Building the Best Engineering "Team"
yuj1osm
1
170
【内製開発Summit 2025】イオンスマートテクノロジーの内製化組織の作り方/In-house-development-summit-AST
aeonpeople
2
660
Featured
See All Featured
Embracing the Ebb and Flow
colly
84
4.6k
Why You Should Never Use an ORM
jnunemaker
PRO
55
9.2k
Optimizing for Happiness
mojombo
376
70k
A designer walks into a library…
pauljervisheath
205
24k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
251
21k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.3k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
49k
BBQ
matthewcrist
87
9.5k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
4
430
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
3.7k
[RailsConf 2023] Rails as a piece of cake
palkan
53
5.3k
Transcript
GPars Promises to keep Václav Pech
About me ['Passionate programmer', 'Concurrency enthusiast', 'GPars lead', 'Developer/technology evangelist
@ JetBrains' ].eachParallel {say it} http://www.jroller.com/vaclav http://twitter.com/vaclav_pech
We're all parallel now Use them or leave them!
None
# of cores
# of cores Today Soon
Dealing with threads sucks! public class Counter { private static
long count = 0; public Counter() { count++; } }
Dealing with threads sucks! public class Counter { private static
long count = 0; public Counter() { synchronized (this) { count++; } } }
Dealing with threads sucks! public class Counter { private static
long count = 0; public Counter() { synchronized (this.getClass()) { count++; } } }
Dealing with threads sucks! public class ClickCounter implements ActionListener {
public ClickCounter(JButton button) { button.addActionListener(this); } public void actionPerformed(final ActionEvent e) { ... } }
images.eachParallel {it.process()} documents.sumParallel() candidates.maxParallel {it.salary}.marry() Parallel Collections
Parallel Collections progLanguages.parallel.filter {it.concurrent} .max {it.javaInteroperability} .map {it.logo} ==
Fork/Join Solve hierarchical problems Divide and conquer
Merge sort, Quick sort Tree traversal File scan / search … [a, b, c, d, e, f, g, h] [a, b, c, d] [e, f, g, h] [a, b] [c, d] [e, f] [g, h]
Thread Pool Tasks Worker threads Queue
Thread Pool Contention!
Fork/Join Thread Pool
Fork/Join Thread Pool Work stealing
Languages are either concurrent or obsolete.
Java 5 Asynchronous calculations
Java 7 Asynchronous calculations Fork/Join
Java 8 Asynchronous calculations Fork/Join Parallel collections
Scala Asynchronous calculations Fork/Join Parallel collections Actors
Clojure Asynchronous calculations Fork/Join Parallel collections Actors Agents, Stm
Oz Asynchronous calculations Fork/Join Parallel collections Actors Agents, Stm Dataflow
Google's Go Asynchronous calculations Fork/Join Parallel collections Actors Agents, Stm
Dataflow CSP
Asynchronous calculations Fork/Join Parallel collections Actors Agents, Stm Dataflow CSP
Asynchronous calculations Fork/Join Parallel collections Actors Agents, Stm Dataflow CSP
Agenda
Actors Processes with a mail-box Share no data Communicate by
sending messages Use a thread-pool
Stateless Actors (pure Java) class MyActor extends DynamicDispatchActor { Account
account = ... public void onMessage(String msg) { String encripted = encrypt(msg); reply(encripted); } public void onMessage(Integer number) { reply(2 * number); } public void onMessage(Money cash) { System.out.println("Received a donation " + cash); account.deposit(cash); } }
Active Objects @ActiveObject class MyCounter { private int counter =
0 @ActiveMethod def incrementBy(int value) { println "Received an integer: $value" this.counter += value } }
Composing async functions int hash1 = hash(download('http://www.gpars.org')) int hash2 =
hash(loadFile('/gpars/website/index.html')) boolean result = compare(hash1, hash2) println result
Composing async functions @AsyncFun hash = oldHash @AsyncFun compare =
oldCompare @AsyncFun download = oldDownload @AsyncFun loadFile = oldLoadFile def hash1 = hash(download('http://www.gpars.org')) def hash2 = hash(loadFile('/gpars/website/index.html')) def result = compare(hash1, hash2) println result.get()
Composing async functions @AsyncFun hash = oldHash @AsyncFun(blocking = true)
compare = oldCompare @AsyncFun download = oldDownload @AsyncFun loadFile = oldLoadFile def hash1 = hash(download('http://www.gpars.org')) def hash2 = hash(loadFile('/gpars/website/index.html')) boolean result = compare(hash1, hash2) println result
int hash(String text) {…} Promise<int> hash(Promise<String> | String text)
int hash(String text) {…} Promise<int> hash(Promise<String> | String text) compare(
hash( download() ), hash( loadFile() ) )
int hash(String text) {…} Promise<int> hash(Promise<String> | String text) {
1.Return a Promise for the result 2.Wait (non-blocking) for the text param 3.Call the original hash() 4.Bind the result }
Composing async functions Combine functions as usual Parallelism is detected
automatically
Dataflow Concurrency No race-conditions No live-locks Deterministic
deadlocks Completely deterministic programs BEAUTIFUL code (Jonas Bonér)
Dataflow Variables / Promises main task2 task3 x y z
task1
Dataflows def df = new Dataflows() task { df.z =
df.x + df.y } task { df.x = 10 } task { println ”I am task 3” df.y = 5 } assert 15 == df.z
operator(inputs: [headers, bodies, footers], outputs: [articles, summaries]) {header, body, footer
-> def article = buildArticle(header, body, footer) bindOutput(0, article) bindOutput(1, buildSummary(article)) } * + <> Dataflow Operators
Url resolver Url resolver Downloader Groovy scanner Scala scanner Url
resolver Url resolver Reporter Speculator Evaluator Splitter Confirm Cache updates Approvals Dataflow Operators
None
'coz concurrency is Groovy Find more at: http://gpars.codehaus.org http://www.jroller.com/vaclav http://twitter.com/vaclav_pech
GPars