![Page 1: Background on Concurrency & Parallelism in Java (Part 2)schmidt/cs891f/2018-PDFs/... · e.g., Java executor framework, synchronizers, blocking queues, atomics, & concurrent collections](https://reader030.vdocument.in/reader030/viewer/2022041015/5ec75e1fe46b2237e7578b0c/html5/thumbnails/1.jpg)
Background on Concurrency &
Parallelism in Java (Part 2)
Douglas C. [email protected]
www.dre.vanderbilt.edu/~schmidt
Professor of Computer Science
Institute for Software
Integrated Systems
Vanderbilt University
Nashville, Tennessee, USA
![Page 2: Background on Concurrency & Parallelism in Java (Part 2)schmidt/cs891f/2018-PDFs/... · e.g., Java executor framework, synchronizers, blocking queues, atomics, & concurrent collections](https://reader030.vdocument.in/reader030/viewer/2022041015/5ec75e1fe46b2237e7578b0c/html5/thumbnails/2.jpg)
2
Learning Objectives in this Part of the Lesson
Additional Frameworks & Languages
Applications
Operating System Kernel
System Libraries
Java Execution Environment (e.g., JVM)
Threading & Synchronization Packages
Java
/JN
IC+
+/C
CJAVA HISTORY
• Understand the meaning of the terms concurrency & parallelism
• Be aware of the history of Java concurrency & parallelism
![Page 3: Background on Concurrency & Parallelism in Java (Part 2)schmidt/cs891f/2018-PDFs/... · e.g., Java executor framework, synchronizers, blocking queues, atomics, & concurrent collections](https://reader030.vdocument.in/reader030/viewer/2022041015/5ec75e1fe46b2237e7578b0c/html5/thumbnails/3.jpg)
3
Learning Objectives in this Part of the Lesson
Hopefully, you’ll already know some of this!!!
• Understand the meaning of the terms concurrency & parallelism
• Be aware of the history of Java concurrency & parallelism Additional Frameworks & Languages
Applications
Operating System Kernel
System Libraries
Java Execution Environment (e.g., JVM)
Threading & Synchronization Packages
Java
/JN
IC+
+/C
C
![Page 4: Background on Concurrency & Parallelism in Java (Part 2)schmidt/cs891f/2018-PDFs/... · e.g., Java executor framework, synchronizers, blocking queues, atomics, & concurrent collections](https://reader030.vdocument.in/reader030/viewer/2022041015/5ec75e1fe46b2237e7578b0c/html5/thumbnails/4.jpg)
4
Learning Objectives in this Part of the Lesson• Understand the meaning of the
terms concurrency & parallelism
• Be aware of the history of Java concurrency & parallelism
• Know which Java mechanism(s) to understand & apply
![Page 5: Background on Concurrency & Parallelism in Java (Part 2)schmidt/cs891f/2018-PDFs/... · e.g., Java executor framework, synchronizers, blocking queues, atomics, & concurrent collections](https://reader030.vdocument.in/reader030/viewer/2022041015/5ec75e1fe46b2237e7578b0c/html5/thumbnails/5.jpg)
5
A Brief History of Concurrency &
Parallelism in Java
![Page 6: Background on Concurrency & Parallelism in Java (Part 2)schmidt/cs891f/2018-PDFs/... · e.g., Java executor framework, synchronizers, blocking queues, atomics, & concurrent collections](https://reader030.vdocument.in/reader030/viewer/2022041015/5ec75e1fe46b2237e7578b0c/html5/thumbnails/6.jpg)
6
A Brief History of Concurrency & Parallelism in Java• Foundational concurrency support
Additional Frameworks & Languages
Applications
Operating System Kernel
System Libraries
Java Execution Environment (e.g., JVM)
Threading & Synchronization Packages
Java
/JN
IC+
+/C
C
e.g., Java threads & built-in monitor objects
available in Java 1.0
![Page 7: Background on Concurrency & Parallelism in Java (Part 2)schmidt/cs891f/2018-PDFs/... · e.g., Java executor framework, synchronizers, blocking queues, atomics, & concurrent collections](https://reader030.vdocument.in/reader030/viewer/2022041015/5ec75e1fe46b2237e7578b0c/html5/thumbnails/7.jpg)
7
A Brief History of Concurrency & Parallelism in Java• Foundational concurrency support
• Focus on basic multi-threading& synchronization primitives
See docs.oracle.com/javase/tutorial/essential/concurrency
![Page 8: Background on Concurrency & Parallelism in Java (Part 2)schmidt/cs891f/2018-PDFs/... · e.g., Java executor framework, synchronizers, blocking queues, atomics, & concurrent collections](https://reader030.vdocument.in/reader030/viewer/2022041015/5ec75e1fe46b2237e7578b0c/html5/thumbnails/8.jpg)
8
A Brief History of Concurrency & Parallelism in Java• Foundational concurrency support
• Focus on basic multi-threading& synchronization primitives
See github.com/douglascraigschmidt/LiveLessons/tree/master/SimpleBlockingQueue
SimpleBlockingBoundedQueue<Integer>
simpleQueue = new
SimpleBlockingBoundedQueue<>();
Thread[] threads = new Thread[] {
new Thread(new Producer<>
(simpleQueue)),
new Thread(new Consumer<>
(simpleQueue))
};
for (Thread thread : threads)
thread.start();
for (Thread thread : threads)
thread.join();
Allow multiple threads to communicate via a
bounded buffer
![Page 9: Background on Concurrency & Parallelism in Java (Part 2)schmidt/cs891f/2018-PDFs/... · e.g., Java executor framework, synchronizers, blocking queues, atomics, & concurrent collections](https://reader030.vdocument.in/reader030/viewer/2022041015/5ec75e1fe46b2237e7578b0c/html5/thumbnails/9.jpg)
9
A Brief History of Concurrency & Parallelism in Java• Foundational concurrency support
• Focus on basic multi-threading& synchronization primitives
See github.com/douglascraigschmidt/LiveLessons/tree/master/SimpleBlockingQueue
Start & join these multiple threads
SimpleBlockingBoundedQueue<Integer>
simpleQueue = new
SimpleBlockingBoundedQueue<>();
Thread[] threads = new Thread[] {
new Thread(new Producer<>
(simpleQueue)),
new Thread(new Consumer<>
(simpleQueue))
};
for (Thread thread : threads)
thread.start();
for (Thread thread : threads)
thread.join();
![Page 10: Background on Concurrency & Parallelism in Java (Part 2)schmidt/cs891f/2018-PDFs/... · e.g., Java executor framework, synchronizers, blocking queues, atomics, & concurrent collections](https://reader030.vdocument.in/reader030/viewer/2022041015/5ec75e1fe46b2237e7578b0c/html5/thumbnails/10.jpg)
10
A Brief History of Concurrency & Parallelism in Java• Foundational concurrency support
• Focus on basic multi-threading& synchronization primitives
See github.com/douglascraigschmidt/LiveLessons/tree/master/SimpleBlockingQueue
class SimpleBlockingBoundedQueue
<E> {
public E take() ...{
synchronized(this) {
while (mList.isEmpty())
wait();
notifyAll();
return mList.poll();
}
}
Built-in monitor object mutual exclusion &
coordination primitives
![Page 11: Background on Concurrency & Parallelism in Java (Part 2)schmidt/cs891f/2018-PDFs/... · e.g., Java executor framework, synchronizers, blocking queues, atomics, & concurrent collections](https://reader030.vdocument.in/reader030/viewer/2022041015/5ec75e1fe46b2237e7578b0c/html5/thumbnails/11.jpg)
11
A Brief History of Concurrency & Parallelism in Java• Foundational concurrency support
• Focus on basic multi-threading& synchronization primitives
• Efficient, but low-level & very limited in capabilities
![Page 12: Background on Concurrency & Parallelism in Java (Part 2)schmidt/cs891f/2018-PDFs/... · e.g., Java executor framework, synchronizers, blocking queues, atomics, & concurrent collections](https://reader030.vdocument.in/reader030/viewer/2022041015/5ec75e1fe46b2237e7578b0c/html5/thumbnails/12.jpg)
12
A Brief History of Concurrency & Parallelism in Java• Foundational concurrency support
• Focus on basic multi-threading& synchronization primitives
• Efficient, but low-level & very limited in capabilities
• Many accidental complexities
See en.wikipedia.org/wiki/No_Silver_Bullet
Accidental complexities arise from limitations with software techniques, tools, & methods
![Page 13: Background on Concurrency & Parallelism in Java (Part 2)schmidt/cs891f/2018-PDFs/... · e.g., Java executor framework, synchronizers, blocking queues, atomics, & concurrent collections](https://reader030.vdocument.in/reader030/viewer/2022041015/5ec75e1fe46b2237e7578b0c/html5/thumbnails/13.jpg)
13
A Brief History of Concurrency & Parallelism in Java• Advanced concurrency support
Additional Frameworks & Languages
Applications
Operating System Kernel
System Libraries
Java Execution Environment (e.g., JVM)
Threading & Synchronization Packages
Java
/JN
IC+
+/C
C
e.g., Java executor framework, synchronizers, blocking queues, atomics, & concurrent collections
available in Java 1.5+
![Page 14: Background on Concurrency & Parallelism in Java (Part 2)schmidt/cs891f/2018-PDFs/... · e.g., Java executor framework, synchronizers, blocking queues, atomics, & concurrent collections](https://reader030.vdocument.in/reader030/viewer/2022041015/5ec75e1fe46b2237e7578b0c/html5/thumbnails/14.jpg)
14
ThreadPoolExecutor
3.take()
4.run()
A Brief History of Concurrency & Parallelism in Java• Advanced concurrency support
• Focus on course-grained “task parallelism” whose computationscan run concurrently
See en.wikipedia.org/wiki/Task_parallelism
WorkerThreads
execute() run()
runnable
runnableFuture
Future
Future
Future
Completion
Queue
runnable
WorkQueue
2.offer()
ExecutorCompletionService
submit()
take()
5.add()
1.submit(task)
6.take()
![Page 15: Background on Concurrency & Parallelism in Java (Part 2)schmidt/cs891f/2018-PDFs/... · e.g., Java executor framework, synchronizers, blocking queues, atomics, & concurrent collections](https://reader030.vdocument.in/reader030/viewer/2022041015/5ec75e1fe46b2237e7578b0c/html5/thumbnails/15.jpg)
15
A Brief History of Concurrency & Parallelism in Java
See github.com/douglascraigschmidt/LiveLessons/tree/master/PalantiriManagerApplication
Create a fixed-sized thread pool & also coordinate the starting & stopping of multiple tasks that
acquire/release shared resources
• Advanced concurrency support
• Focus on course-grained “task parallelism” whose computationscan run concurrently
ExecutorService executor =
Executors.newFixedThreadPool
(numOfBeings,
mThreadFactory);
...
CyclicBarrier entryBarrier =
new CyclicBarrier(numOfBeings+1);
CountDownLatch exitBarrier =
new CountDownLatch(numOfBeings);
for (int i=0; i < beingCount; ++i)
executor.execute
(makeBeingRunnable(i,
entryBarrier,
exitBarrier));
![Page 16: Background on Concurrency & Parallelism in Java (Part 2)schmidt/cs891f/2018-PDFs/... · e.g., Java executor framework, synchronizers, blocking queues, atomics, & concurrent collections](https://reader030.vdocument.in/reader030/viewer/2022041015/5ec75e1fe46b2237e7578b0c/html5/thumbnails/16.jpg)
16
A Brief History of Concurrency & Parallelism in Java• Advanced concurrency support
• Focus on course-grained “task parallelism” whose computationscan run concurrently
• Feature-rich & optimized, but also tedious & error-prone to program
![Page 17: Background on Concurrency & Parallelism in Java (Part 2)schmidt/cs891f/2018-PDFs/... · e.g., Java executor framework, synchronizers, blocking queues, atomics, & concurrent collections](https://reader030.vdocument.in/reader030/viewer/2022041015/5ec75e1fe46b2237e7578b0c/html5/thumbnails/17.jpg)
17
A Brief History of Concurrency & Parallelism in Java• Foundational parallelism support
Additional Frameworks & Languages
Applications
Operating System Kernel
System Libraries
Java Execution Environment (e.g., JVM)
Threading & Synchronization Packages
Java
/JN
IC+
+/C
C
e.g., Java fork-join pool available in Java 1.7
![Page 18: Background on Concurrency & Parallelism in Java (Part 2)schmidt/cs891f/2018-PDFs/... · e.g., Java executor framework, synchronizers, blocking queues, atomics, & concurrent collections](https://reader030.vdocument.in/reader030/viewer/2022041015/5ec75e1fe46b2237e7578b0c/html5/thumbnails/18.jpg)
18
A Brief History of Concurrency & Parallelism in Java• Foundational parallelism support
• Focus on data parallelism that runs the same task on different data elements
See en.wikipedia.org/wiki/Data_parallelism
join join
join
Processsequentially
Processsequentially
Processsequentially
Processsequentially
Sub-task1.1 Sub-task1.2 Sub-task2.1 Sub-task2.2
Sub-task1 Sub-task2
fork()
Task
fork() fork()
![Page 19: Background on Concurrency & Parallelism in Java (Part 2)schmidt/cs891f/2018-PDFs/... · e.g., Java executor framework, synchronizers, blocking queues, atomics, & concurrent collections](https://reader030.vdocument.in/reader030/viewer/2022041015/5ec75e1fe46b2237e7578b0c/html5/thumbnails/19.jpg)
19See github.com/douglascraigschmidt/LiveLessons/tree/master/SearchForkJoin
A Brief History of Concurrency & Parallelism in Java• Foundational parallelism support
• Focus on data parallelism that runs the same task on different data elements
List<List<SearchResults>>
listOfListOfSearchResults =
ForkJoinPool
.commonPool()
.invoke(new
SearchWithForkJoinTask
(inputList,
mPhrasesToFind, ...));
Use a common fork-join pool to search input strings to locate phrases that match
45,000+ phrases
Search Phrases
Input Strings to Search
…
![Page 20: Background on Concurrency & Parallelism in Java (Part 2)schmidt/cs891f/2018-PDFs/... · e.g., Java executor framework, synchronizers, blocking queues, atomics, & concurrent collections](https://reader030.vdocument.in/reader030/viewer/2022041015/5ec75e1fe46b2237e7578b0c/html5/thumbnails/20.jpg)
20
A Brief History of Concurrency & Parallelism in Java• Foundational parallelism support
• Focus on data parallelism that runs the same task on different data elements
• Powerful & scalable, but tedious to program directly
join join
join
Processsequentially
Processsequentially
Processsequentially
Processsequentially
Sub-task1.1 Sub-task1.2 Sub-task2.1 Sub-task2.2
Sub-task1 Sub-task2
fork()
Task
fork() fork()
![Page 21: Background on Concurrency & Parallelism in Java (Part 2)schmidt/cs891f/2018-PDFs/... · e.g., Java executor framework, synchronizers, blocking queues, atomics, & concurrent collections](https://reader030.vdocument.in/reader030/viewer/2022041015/5ec75e1fe46b2237e7578b0c/html5/thumbnails/21.jpg)
21
A Brief History of Concurrency & Parallelism in Java• Advanced parallelism support
Additional Frameworks & Languages
Applications
Operating System Kernel
System Libraries
Java Execution Environment (e.g., JVM)
Threading & Synchronization Packages
Java
/JN
IC+
+/C
C
e.g., Java parallel streams & completable futures available in Java 1.8
![Page 22: Background on Concurrency & Parallelism in Java (Part 2)schmidt/cs891f/2018-PDFs/... · e.g., Java executor framework, synchronizers, blocking queues, atomics, & concurrent collections](https://reader030.vdocument.in/reader030/viewer/2022041015/5ec75e1fe46b2237e7578b0c/html5/thumbnails/22.jpg)
22
A Brief History of Concurrency & Parallelism in Java
filter(not(this::urlCached))
collect(toList())
Parallel Streams
…
map(this::downloadImage)
flatMap(this::applyFilters)
• Advanced parallelism support
• Focus on functional programming for data parallelism
See en.wikipedia.org/wiki/Data_parallelism
![Page 23: Background on Concurrency & Parallelism in Java (Part 2)schmidt/cs891f/2018-PDFs/... · e.g., Java executor framework, synchronizers, blocking queues, atomics, & concurrent collections](https://reader030.vdocument.in/reader030/viewer/2022041015/5ec75e1fe46b2237e7578b0c/html5/thumbnails/23.jpg)
23
A Brief History of Concurrency & Parallelism in Java• Advanced parallelism support
• Focus on functional programming for data parallelism & reactiveasynchrony
/page\ =
supplyAsync
(getStartPage())
/imgNum2\ = /page\
.thenComposeAsync
(crawlHyperLinks
(page))
/imgNum1\ = /page\
.thenApplyAsync
(countImages(page))
.thenApply(List::size)
/imgNum1\.thenCombine(/imgNum2\,
(imgNum1, imgNum2) ->
Integer::sum)
See gist.github.com/staltz/868e7e9bc2a7b8c1f754
![Page 24: Background on Concurrency & Parallelism in Java (Part 2)schmidt/cs891f/2018-PDFs/... · e.g., Java executor framework, synchronizers, blocking queues, atomics, & concurrent collections](https://reader030.vdocument.in/reader030/viewer/2022041015/5ec75e1fe46b2237e7578b0c/html5/thumbnails/24.jpg)
24
A Brief History of Concurrency & Parallelism in Java• Advanced parallelism support
• Focus on functional programming for data parallelism & reactiveasynchrony
See github.com/douglascraigschmidt/LiveLessons/tree/master/ImageStreamGang
Synchronously download images that aren’t already cached from a list of URLs
& process/store the images in parallel
List<Image> images =
urls
.parallelStream()
.filter(not(this::urlCached))
.map(this::downloadImage)
.flatMap(this::applyFilters)
.collect(toList());
![Page 25: Background on Concurrency & Parallelism in Java (Part 2)schmidt/cs891f/2018-PDFs/... · e.g., Java executor framework, synchronizers, blocking queues, atomics, & concurrent collections](https://reader030.vdocument.in/reader030/viewer/2022041015/5ec75e1fe46b2237e7578b0c/html5/thumbnails/25.jpg)
25
A Brief History of Concurrency & Parallelism in Java• Advanced parallelism support
• Focus on functional programming for data parallelism & reactiveasynchrony
See github.com/douglascraigschmidt/LiveLessons/tree/master/ImageStreamGang
CompletableFuture<Stream<Image>>
resultsFuture = urls
.stream()
.map(this::checkUrlCachedAsync)
.map(this::downloadImageAsync)
.flatMap(this::applyFiltersAsync)
.collect(toFuture())
.thenApply(stream ->
log(stream.flatMap
(Optional::stream),
urls.size()))
.join();
Asynchronously download images that aren’t already cached from a list of URLs
& process/store the images in parallel
![Page 26: Background on Concurrency & Parallelism in Java (Part 2)schmidt/cs891f/2018-PDFs/... · e.g., Java executor framework, synchronizers, blocking queues, atomics, & concurrent collections](https://reader030.vdocument.in/reader030/viewer/2022041015/5ec75e1fe46b2237e7578b0c/html5/thumbnails/26.jpg)
26
A Brief History of Concurrency & Parallelism in Java• Advanced parallelism support
• Focus on functional programming for data parallelism & reactiveasynchrony
• Strikes an effective balance between productivity & performance
![Page 27: Background on Concurrency & Parallelism in Java (Part 2)schmidt/cs891f/2018-PDFs/... · e.g., Java executor framework, synchronizers, blocking queues, atomics, & concurrent collections](https://reader030.vdocument.in/reader030/viewer/2022041015/5ec75e1fe46b2237e7578b0c/html5/thumbnails/27.jpg)
27
A Brief History of Concurrency & Parallelism in Java• Advanced parallelism support
• Focus on functional programming for data parallelism & reactiveasynchrony
• Strikes an effective balance between productivity & performance
• However, may be overly prescriptive
![Page 28: Background on Concurrency & Parallelism in Java (Part 2)schmidt/cs891f/2018-PDFs/... · e.g., Java executor framework, synchronizers, blocking queues, atomics, & concurrent collections](https://reader030.vdocument.in/reader030/viewer/2022041015/5ec75e1fe46b2237e7578b0c/html5/thumbnails/28.jpg)
28
Which Java Mechanism(s) to Understand & Apply
![Page 29: Background on Concurrency & Parallelism in Java (Part 2)schmidt/cs891f/2018-PDFs/... · e.g., Java executor framework, synchronizers, blocking queues, atomics, & concurrent collections](https://reader030.vdocument.in/reader030/viewer/2022041015/5ec75e1fe46b2237e7578b0c/html5/thumbnails/29.jpg)
29
Which Java Mechanism(s) to Understand & Apply• Java’s concurrency & parallelism
mechanisms span multiple layersin the software stack
Additional Application Frameworks
Operating System Kernel
Applications
System Libraries
Execution Environment (JVM, Dalvik/ART, etc.)
Java
/JN
IC+
+/C
C
Concurrency/Parallelism Frameworks
Java Threads & Synchronizers
![Page 30: Background on Concurrency & Parallelism in Java (Part 2)schmidt/cs891f/2018-PDFs/... · e.g., Java executor framework, synchronizers, blocking queues, atomics, & concurrent collections](https://reader030.vdocument.in/reader030/viewer/2022041015/5ec75e1fe46b2237e7578b0c/html5/thumbnails/30.jpg)
30
Which Java Mechanism(s) to Understand & Apply• Java’s concurrency & parallelism
mechanisms span multiple layersin the software stack
• Choosing best mechanism(s) depend on various factors
Additional Application Frameworks
Operating System Kernel
Applications
System Libraries
Execution Environment (JVM, Dalvik/ART, etc.)
Java
/JN
IC+
+/C
C
Concurrency/Parallelism Frameworks
Java Threads & Synchronizers
![Page 31: Background on Concurrency & Parallelism in Java (Part 2)schmidt/cs891f/2018-PDFs/... · e.g., Java executor framework, synchronizers, blocking queues, atomics, & concurrent collections](https://reader030.vdocument.in/reader030/viewer/2022041015/5ec75e1fe46b2237e7578b0c/html5/thumbnails/31.jpg)
31
Additional Application Frameworks
Operating System Kernel
Applications
System Libraries
Execution Environment (JVM, Dalvik/ART, etc.)
Java
/JN
IC+
+/C
C
Concurrency/Parallelism Frameworks
Java Threads & Synchronizers
Which Java Mechanism(s) to Understand & Apply• Developers of low-level classes &
performance-sensitive apps may prefer shared object mechanisms
e.g., java.util.concurrent as per www.youtube.com/watch?v=sq0MX3fHkro
![Page 32: Background on Concurrency & Parallelism in Java (Part 2)schmidt/cs891f/2018-PDFs/... · e.g., Java executor framework, synchronizers, blocking queues, atomics, & concurrent collections](https://reader030.vdocument.in/reader030/viewer/2022041015/5ec75e1fe46b2237e7578b0c/html5/thumbnails/32.jpg)
32
Additional Application Frameworks
Operating System Kernel
Applications
System Libraries
Execution Environment (JVM, Dalvik/ART, etc.)
Java
/JN
IC+
+/C
C
Concurrency/Parallelism Frameworks
Java Threads & Synchronizers
Which Java Mechanism(s) to Understand & Apply• Developers of low-level classes &
performance-sensitive apps may prefer shared object mechanisms
• Pros: Efficient & lightweight
• Cons: Tedious & error-prone
![Page 33: Background on Concurrency & Parallelism in Java (Part 2)schmidt/cs891f/2018-PDFs/... · e.g., Java executor framework, synchronizers, blocking queues, atomics, & concurrent collections](https://reader030.vdocument.in/reader030/viewer/2022041015/5ec75e1fe46b2237e7578b0c/html5/thumbnails/33.jpg)
33
Additional Application Frameworks
Operating System Kernel
Applications
System Libraries
Execution Environment (JVM, Dalvik/ART, etc.)
Java
/JN
IC+
+/C
C
Concurrency/Parallelism Frameworks
Java Threads & Synchronizers
Which Java Mechanism(s) to Understand & Apply• Framework developers may want
to use the Java message passing mechanisms
e.g., Android AsyncTask/HaMeR frameworks or Java ExecutorCompetionService
![Page 34: Background on Concurrency & Parallelism in Java (Part 2)schmidt/cs891f/2018-PDFs/... · e.g., Java executor framework, synchronizers, blocking queues, atomics, & concurrent collections](https://reader030.vdocument.in/reader030/viewer/2022041015/5ec75e1fe46b2237e7578b0c/html5/thumbnails/34.jpg)
34
Additional Application Frameworks
Operating System Kernel
Applications
System Libraries
Execution Environment (JVM, Dalvik/ART, etc.)
Java
/JN
IC+
+/C
C
Concurrency/Parallelism Frameworks
Java Threads & Synchronizers
Which Java Mechanism(s) to Understand & Apply• Framework developers may want
to use the Java message passing mechanisms
• Pros: Flexible & decoupled
• Cons: Time/space overhead
![Page 35: Background on Concurrency & Parallelism in Java (Part 2)schmidt/cs891f/2018-PDFs/... · e.g., Java executor framework, synchronizers, blocking queues, atomics, & concurrent collections](https://reader030.vdocument.in/reader030/viewer/2022041015/5ec75e1fe46b2237e7578b0c/html5/thumbnails/35.jpg)
35
Additional Application Frameworks
Operating System Kernel
Applications
System Libraries
Execution Environment (JVM, Dalvik/ART, etc.)
Java
/JN
IC+
+/C
C
Concurrency/Parallelism Frameworks
Java Threads & Synchronizers
Which Java Mechanism(s) to Understand & Apply
e.g., Java 8 parallel streams & completable futures, RxJava, etc.
• Mobile app developers may want toprogram w/higher-level frameworks
![Page 36: Background on Concurrency & Parallelism in Java (Part 2)schmidt/cs891f/2018-PDFs/... · e.g., Java executor framework, synchronizers, blocking queues, atomics, & concurrent collections](https://reader030.vdocument.in/reader030/viewer/2022041015/5ec75e1fe46b2237e7578b0c/html5/thumbnails/36.jpg)
36
Additional Application Frameworks
Operating System Kernel
Applications
System Libraries
Execution Environment (JVM, Dalvik/ART, etc.)
Java
/JN
IC+
+/C
C
Concurrency/Parallelism Frameworks
Java Threads & Synchronizers
Which Java Mechanism(s) to Understand & Apply• Mobile app developers may want to
program w/higher-level frameworks
• Pros: Productivity & robustness
• Cons: Time/space overhead& overly prescriptive
![Page 37: Background on Concurrency & Parallelism in Java (Part 2)schmidt/cs891f/2018-PDFs/... · e.g., Java executor framework, synchronizers, blocking queues, atomics, & concurrent collections](https://reader030.vdocument.in/reader030/viewer/2022041015/5ec75e1fe46b2237e7578b0c/html5/thumbnails/37.jpg)
37
Additional Application Frameworks
Operating System Kernel
Applications
System Libraries
Execution Environment (JVM, Dalvik/ART, etc.)
Java
/JN
IC+
+/C
C
Concurrency/Parallelism Frameworks
Java Threads & Synchronizers
Which Java Mechanism(s) to Understand & Apply
“Full stack” developers should understand concepts & mechanisms at each layer
![Page 38: Background on Concurrency & Parallelism in Java (Part 2)schmidt/cs891f/2018-PDFs/... · e.g., Java executor framework, synchronizers, blocking queues, atomics, & concurrent collections](https://reader030.vdocument.in/reader030/viewer/2022041015/5ec75e1fe46b2237e7578b0c/html5/thumbnails/38.jpg)
38
End of Background on Java Concurrency & Parallelism (Part 2)