Benefits of Concurrency in Java & Android: Program Structure
|
|
- Eleanore Underwood
- 5 years ago
- Views:
Transcription
1 Benefits of Concurrency in Java & Android: Program Structure Douglas C. Schmidt Institute for Software Integrated Systems Vanderbilt University Nashville, Tennessee, USA
2 Learning Objectives in this Part of the Module Recognize how concurrency can improve performance in Java & Android Recognize how concurrency can improve responsiveness in Java & Android Recognize how concurrency can improve program structure in Java & Android 2
3 Overview of Event-Driven Programs 3
4 Overview of Event-Driven Programs Many software programs have historically been structured via a purely eventdriven programming model See en.wikipedia.org/wiki/ 4 Event-driven_programming
5 Overview of Event-Driven Programs Many software programs have historically been structured via a purely eventdriven programming model The program flow is guided by events See developer.android.com/guide/ 5 components/activities/activity-lifecycle.html
6 Overview of Event-Driven Programs Many software programs have historically been structured via a purely eventdriven programming model The program flow is guided by events e.g., user interface actions, sensor I/O, messages from elsewhere, etc. Button button = (Button) findviewbyid(r.id.loadbutton); button.setonclicklistener(new OnClickListener() public void onclick(view v) { }}); A GUI component sending an event to its registered listener GUI Component (e.g., a button) 6
7 Overview of Event-Driven Programs Many software programs have historically been structured via a purely eventdriven programming model The program flow is guided by events Event-driven programming is a common model in GUIs that perform actions in response to user input Queue e.g., a single event loop in the Android UI thread processes all the user-facing events Event Loop UI Thread (main thread) See developer.android.com/training/ 7 multiple-threads/communicate-ui.html
8 Limitations with Purely Event-Driven Programs 8
9 Limitations with Purely Event-Driven Programs For certain types of apps purely event-driven software is hard to understand & is inefficient Queue Event Loop UI Thread (main thread) 9
10 Limitations with Purely Event-Driven Programs For certain types of apps purely event-driven software is hard to understand & is inefficient e.g., an app that downloads/displays images from web servers Queue Event Loop UI Thread (main thread) 10
11 Limitations with Purely Event-Driven Programs For certain types of apps purely event-driven software is hard to understand & is inefficient e.g., an app that downloads/displays images from web servers Queue To avoid starvation of other tasks, long-duration blocking operations are disallowed in the UI thread Event Loop UI Thread (main thread) Moreover, there s just a single 11 thread, i.e., the UI thread!
12 Limitations with Purely Event-Driven Programs For certain types of apps purely event-driven software is hard to understand & is inefficient e.g., an app that downloads/displays images from web servers Queue Event Loop Long-duration operations are run asynchronously by posting messages in the message queue of the UI thread s event loop UI Thread (main thread) 12
13 Limitations with Purely Event-Driven Programs For certain types of apps purely event-driven software is hard to understand & is inefficient e.g., an app that downloads/displays images from web servers Queue Event Loop e.g., a message requesting an asynchronous read of a socket could be posted to the UI thread s event loop UI Thread (main thread) 13
14 Limitations with Purely Event-Driven Programs For certain types of apps purely event-driven software is hard to understand & is inefficient e.g., an app that downloads/displays images from web servers Queue Asynchronous operation completion is handled later via messages in the UI thread s event loop Event Loop UI Thread (main thread) 14
15 Limitations with Purely Event-Driven Programs For certain types of apps purely event-driven software is hard to understand & is inefficient e.g., an app that downloads/displays images from web servers Queue Event Loop e.g., the completion of the async read indicates how many bytes were read in from the socket UI Thread (main thread) 15
16 Limitations with Purely Event-Driven Programs For certain types of apps purely event-driven software is hard to understand & is inefficient e.g., an app that downloads/displays images from web servers These steps may be repeated multiple times until the image is completely downloaded Event Loop Queue UI Thread (main thread) See en.wikipedia.org/wiki/lather,_rinse,_repeat 16
17 Limitations with Purely Event-Driven Programs For certain types of apps purely event-driven software is hard to understand & is inefficient e.g., an app that downloads/displays images from web servers These steps may be repeated multiple times until the image is completely downloaded Event Loop Queue UI Thread (main thread) Note the disconnect in both time & space between 17 operation invocation & operation completion
18 Limitations with Purely Event-Driven Programs Poorly structured event-driven software often leads to spaghetti code or a big ball of mud See en.wikipedia.org/wiki/spaghetti_code 18 & en.wikipedia.org/wiki/big_ball_of_mud
19 Limitations with Purely Event-Driven Programs Poorly structured event-driven software often leads to spaghetti code or a big ball of mud This type of code is hard to understand since there s little/no structure or linear flow of control to guide developers 19
20 Limitations with Purely Event-Driven Programs Poorly structured event-driven software often leads to spaghetti code or a big ball of mud This type of code is hard to understand since there s little/no structure or linear flow of control to guide developers Single-threaded programs that are driven purely by events can obscure the flow of control in time & space Step 2 Step 5 Step 3 Step 4 Step 6 Step 1 20
21 Limitations with Purely Event-Driven Programs Poorly structured event-driven software often leads to spaghetti code or a big ball of mud This type of code is hard to understand since there s little/no structure or linear flow of control to guide developers Single-threaded programs that are driven purely by events can obscure the flow of control in time & space Step 2 Step 5 Step 3 Step 4 Step 6 Step 1 It s hard to understand software when its 21 flow of control bounces all over the place
22 Limitations with Purely Event-Driven Programs Poorly structured event-driven software often leads to spaghetti code or a big ball of mud This type of code is hard to understand since there s little/no structure or linear flow of control to guide developers Single-threaded programs that are driven purely by events can obscure the flow of control in time & space It s also hard to sustain since small changes can break nearly anything due to non-intuitive dependencies 22
23 Simplifying Program Structure with Concurrency 23
24 Simplifying Program Structure with Concurrency Concurrency mechanisms & frameworks can help overcome drawbacks with purely event-driven programs 24
25 Simplifying Program Structure with Concurrency Concurrency mechanisms & frameworks can help overcome drawbacks with purely event-driven programs Multi-threading enables more intuitive (& often performant) ways to structure software See en.wikipedia.org/wiki/ 25 Multithreading_(computer_architecture)
26 Simplifying Program Structure with Concurrency Concurrency mechanisms & frameworks can help overcome drawbacks with purely event-driven programs Multi-threading enables more intuitive (& often performant) ways to structure software e.g., operations that run for long-durations can block synchronously 26
27 Simplifying Program Structure with Concurrency Concurrency mechanisms & frameworks can help overcome drawbacks with purely event-driven programs Multi-threading enables more intuitive (& often performant) ways to structure software e.g., operations that run for long-durations can block synchronously Synchronous blocking within a thread can often 27 yield a more natural & collaborative control flow
28 Simplifying Program Structure with Concurrency Android s HaMeR concurrency framework can help simplify program structure Queue Background Thread A Handler Looper Handler Runnable Background Thread B UI Thread (main thread) See next part of this lesson for 28 an Android example for this code
29 Simplifying Program Structure with Concurrency Android s HaMeR concurrency framework can help simplify program structure Operations that run for long-durations can block in threads Queue Handler Background Thread A Looper Handler Runnable Background Thread B UI Thread (main thread) 29
30 Simplifying Program Structure with Concurrency Android s HaMeR concurrency framework can help simplify program structure Queue Background Thread A Handler Looper Handler Runnable Short-duration operations run in the UI thread & don t block Background Thread B UI Thread (main thread) 30
31 Simplifying Program Structure with Concurrency Android s HaMeR concurrency framework can help simplify program structure Queue Background Thread A Android s HaMeR concurrency Short-duration framework supports a hybrid operations run in programming model, i.e., part the UI thread & concurrent (half-sync) & part don t block event-driven (half-async) Looper Handler Handler Runnable Background Thread B UI Thread (main thread) See 31
32 Simplifying Program Structure with Concurrency Android s HaMeR concurrency framework can help simplify program structure Queue Background Thread A Handler Looper Handler Runnable Background Thread B UI Thread (main thread) No more spaghetti code or big ball of mud since the app is neatly 32 organized in a more linear structure that doesn t bounce around!
33 Simplifying Program Structure with Concurrency Android s HaMeR concurrency framework can help simplify program structure This framework implements various POSA concurrency patterns e.g., Command Processor, Active Object, Half-Sync/Half-Async Queue Handler Background Thread A Looper Handler Runnable Background Thread B UI Thread (main thread) See 33 & en.wikipedia.org/wiki/concurrency_pattern
34 End of Benefits of Concurrency in Java & Android (Part 3) 34
35 Discussion Questions 1. Which of the following are problems with poorly structured event-driven programs? a. It s performance & responsiveness are poor since there is little/no structure or linear flow of control to guide developers b. It s hard to understand since there s little/no structure or linear flow of control to guide developers c. It s hard to sustain since small changes can break nearly anything due to non-intuitive dependencies d. Synchronous blocking in threads can often yield a less natural & collaborative control flow 35
36 Discussion Questions 2. How does concurrency help to simplify program structure? a. It provides a disconnect in both time & space between operation invocation & operation completion b. Concurrent programs can obscure the flow of control in both time & space c. Synchronous blocking within a thread can often yield a more natural & collaborative control flow d. Synchronous blocking within a thread can often yield a less natural & collaborative control flow 36
37 Benefits of Concurrency in Android: App Case Study Douglas C. Schmidt Institute for Software Integrated Systems Vanderbilt University Nashville, Tennessee, USA
38 Learning Objectives in this Part of the Module Recognize how concurrency can improve performance in Java & Android Recognize how concurrency can improve responsiveness in Java & Android Recognize how concurrency can improve program structure in Java & Android Know how concurrency benefits can be applied to avoid overly complex & tangled event-driven solutions in Java & Android e.g., an app that concurrently downloads an image 2 from a remote web server & displays it to the user
39 Analyzing the Image Download App 3
40 Analyzing the Image Download App This app downloads images from remote web servers & displays them Socket Socket See github.com/douglascraigschmidt/posa/ 4 tree/master/ex/m3/imagedownloader/sync
41 Analyzing the Image Download App This app downloads images from remote web servers & displays them Uses a Java thread with a runnable implementation to download images Socket Socket Allows image downloading to take 5 advantage of multi-core processors
42 Analyzing the Image Download App This app downloads images from remote web servers & displays them Uses a Java thread with a runnable implementation to download images The following lambda expression specifies what work the thread should run new Thread(() -> { /* Code to run goes here */ }).start(); The Java 8 version using lambda expressions is 6 very concise since it omits all unnecessary syntax!
43 Analyzing the Image Download App This app downloads images from remote web servers & displays them Uses a Java thread with a runnable implementation to download images The following lambda expression specifies what work the thread should run new Thread(() -> { /* Code to run goes here */ }).start(); The Java Thread class creates & controls the unit of execution that processes the lambda expression See docs.oracle.com/javase/tutorial/ 7 essential/concurrency/runthread.html
44 Analyzing the Image Download App This app downloads images from remote web servers & displays them Uses a Java thread with a runnable implementation to download images See upcoming lesson on 8 Overview of Java Threads
45 Analyzing the Image Download App This app downloads images from remote web servers & displays them Uses a Java thread with a runnable implementation to download images Uses Android HaMeR concurrency framework to pass results to UI thread Socket Socket See code.tutsplus.com/tutorials/concurrency-onandroid-using-hamer-framework--cms
46 Analyzing the Image Download App This app downloads images from remote web servers & displays them Uses a Java thread with a runnable implementation to download images Uses Android HaMeR concurrency framework to pass results to UI thread Socket Socket Downloading of images is 10 done in background threads
47 Analyzing the Image Download App This app downloads images from remote web servers & displays them Uses a Java thread with a runnable implementation to download images Uses Android HaMeR concurrency framework to pass results to UI thread Socket Socket Displaying of images is 11 done in the UI thread
48 Analyzing the Image Download App This app downloads images from remote web servers & displays them Uses a Java thread with a runnable implementation to download images Uses Android HaMeR concurrency framework to pass results to UI thread This solution intentionally doesn t handle interrupts or runtime configuration changes Socket Socket See upcoming lesson on Managing 12 the Java Thread Lifecycle
49 Analyzing the Image Download App As a reminder, the purely event-driven solution was not cohesive Note disconnect between operation invocation & operation completion in both time & space Event Loop Queue UI Thread (main thread) See the previous part 13 of this lesson for details
50 Analyzing the Image Download App The structure of this concurrent app is more cohesive in time & space Called when user presses download button public void downloadimage(view view) { Uri url = geturl(); showdialog("downloading via HaMeR"); startdownload(url); 14
51 Analyzing the Image Download App The structure of this concurrent app is more cohesive in time & space public void downloadimage(view view) { Uri url = geturl(); showdialog("downloading via HaMeR"); startdownload(url); Get the URL entered by user 15
52 Analyzing the Image Download App The structure of this concurrent app is more cohesive in time & space public void downloadimage(view view) { Uri url = geturl(); showdialog("downloading via HaMeR"); startdownload(url); Display dialog to user while download is in progress 16
53 Analyzing the Image Download App The structure of this concurrent app is more cohesive in time & space public void downloadimage(view view) { Uri url = geturl(); showdialog("downloading via HaMeR"); startdownload(url); Initiate downloading of the image at the url 17
54 Analyzing the Image Download App The structure of this concurrent app is more cohesive in time & space Performs the image download public void startdownload(uri url) { new Thread(() -> { Uri pathname = downloadimage(this, url); runonuithread(() -> displayimage(pathname)); }).start(); 18
55 Analyzing the Image Download App The structure of this concurrent app is more cohesive in time & space public void startdownload(uri url) { new Thread(() -> { Uri pathname = downloadimage(this, url); Define a lambda expression runonuithread(() -> displayimage(pathname)); }).start(); 19
56 Analyzing the Image Download App The structure of this concurrent app is more cohesive in time & space public void startdownload(uri url) { new Thread(() -> { Uri pathname = downloadimage(this, url); runonuithread(() -> displayimage(pathname)); }).start(); Start a new thread Runtime thread stack See developer.android.com/guide/components/ 20 processes-and-threads.html#workerthreads
57 Analyzing the Image Download App The structure of this concurrent app is more cohesive in time & space public void startdownload(uri url) { new Thread(() -> { Uri pathname = downloadimage(this, url); Blocks downloading image in background thread runonuithread(() -> displayimage(pathname)); }).start(); 21
58 Analyzing the Image Download App The structure of this concurrent app is more cohesive in time & space public void startdownload(uri url) { new Thread(() -> { Uri pathname = downloadimage(this, url); Create command to run in UI thread (non-blocking) runonuithread(() -> displayimage(pathname)); }).start(); See 22 ~schmidt/commandprocessor.pdf
59 Analyzing the Image Download App The structure of this concurrent app is more cohesive in time & space public void startdownload(uri url) { new Thread(() -> { Uri pathname = downloadimage(this, url); runonuithread(() -> displayimage(pathname)); }).start(); Display image in UI thread (non-blocking) 23
60 Analyzing the Image Download App The structure of this concurrent app is more cohesive in time & space public void startdownload(uri url) { new Thread(() -> { Uri pathname = downloadimage(this, url); These methods run in different threads runonuithread(() -> displayimage(pathname)); }).start(); 24
61 Analyzing the Image Download App The structure of this concurrent app is more cohesive in time & space public void startdownload(uri url) { new Thread(() -> { Uri pathname = downloadimage(this, url); runonuithread(() -> displayimage(pathname)); }).start(); The Android HaMeR-based version of this code is easier to understand than the 25 purely event-driven version since it doesn t bounce around in time & space!
62 End of Benefits of Concurrency in Java & Android (Part 4) 26
63 Discussion Questions 1. Which of the following are reasons why the concurrent version of the app is better structured than the purely event-driven version? a. It can take advantage of Java 8 programming language features, such as lambda expressions b. It can take advantage of multi-core processors to run downloads in parallel c. It is more cohesive in time & space since the code that downloads an image can block synchronously d. It is more cohesive in time & space since the code that downloads an image must run asynchronously without blocking 27
Overview of Java Threads (Part 2)
Overview of Java Threads (Part 2) Douglas C. Schmidt d.schmidt@vanderbilt.edu www.dre.vanderbilt.edu/~schmidt Institute for Software Integrated Systems Vanderbilt University Nashville, Tennessee, USA Learning
More informationInfrastructure Middleware (Part 3): Android Runtime Core & Native Libraries
Infrastructure Middleware (Part 3): Android Runtime Core & Native Libraries Douglas C. Schmidt d.schmidt@vanderbilt.edu www.dre.vanderbilt.edu/~schmidt Institute for Software Integrated Systems Vanderbilt
More informationOverview of Java Threads (Part 3)
Overview of Java Threads (Part 3) Douglas C. Schmidt d.schmidt@vanderbilt.edu www.dre.vanderbilt.edu/~schmidt Institute for Software Integrated Systems Vanderbilt University Nashville, Tennessee, USA Learning
More informationInfrastructure Middleware (Part 1): Hardware Abstraction Layer (HAL)
Infrastructure Middleware (Part 1): Douglas C. Schmidt d.schmidt@vanderbilt.edu www.dre.vanderbilt.edu/~schmidt Institute for Software Integrated Systems Vanderbilt University Nashville, Tennessee, USA
More informationThe Java ExecutorService (Part 1)
The Java ExecutorService (Part 1) Douglas C. Schmidt d.schmidt@vanderbilt.edu www.dre.vanderbilt.edu/~schmidt Institute for Software Integrated Systems Vanderbilt University Nashville, Tennessee, USA Learning
More informationThe Java Executor (Part 1)
The Java Executor (Part 1) Douglas C. Schmidt d.schmidt@vanderbilt.edu www.dre.vanderbilt.edu/~schmidt Institute for Software Integrated Systems Vanderbilt University Nashville, Tennessee, USA Learning
More informationAndroid Services & Local IPC: The Command Processor Pattern (Part 1)
: The Command Processor Pattern (Part 1) d.schmidt@vanderbilt.edu www.dre.vanderbilt.edu/~schmidt Professor of Computer Science Institute for Software Integrated Systems Vanderbilt University Nashville,
More informationJava 8 Parallel ImageStreamGang Example (Part 3)
Java 8 Parallel ImageStreamGang Example (Part 3) Douglas C. Schmidt d.schmidt@vanderbilt.edu www.dre.vanderbilt.edu/~schmidt Professor of Computer Science Institute for Software Integrated Systems Vanderbilt
More informationJava Monitor Objects: Synchronization (Part 1)
Java Monitor Objects: Synchronization (Part 1) Douglas C. Schmidt d.schmidt@vanderbilt.edu www.dre.vanderbilt.edu/~schmidt Institute for Software Integrated Systems Vanderbilt University Nashville, Tennessee,
More informationJava Semaphore (Part 1)
Java Semaphore (Part 1) Douglas C. Schmidt d.schmidt@vanderbilt.edu www.dre.vanderbilt.edu/~schmidt Institute for Software Integrated Systems Vanderbilt University Nashville, Tennessee, USA Learning Objectives
More informationOverview of Layered Architectures
Overview of ed Architectures Douglas C. Schmidt d.schmidt@vanderbilt.edu www.dre.vanderbilt.edu/~schmidt Professor of Computer Science Institute for Software Integrated Systems Vanderbilt University Nashville,
More informationJava ReentrantLock (Part 1)
Java ReentrantLock (Part 1) Douglas C. Schmidt d.schmidt@vanderbilt.edu www.dre.vanderbilt.edu/~schmidt Institute for Software Integrated Systems Vanderbilt University Nashville, Tennessee, USA Learning
More informationJava Barrier Synchronizers: CountDownLatch (Part 1)
Java Barrier Synchronizers: CountDownLatch (Part 1) Douglas C. Schmidt d.schmidt@vanderbilt.edu www.dre.vanderbilt.edu/~schmidt Institute for Software Integrated Systems Vanderbilt University Nashville,
More informationOverview of Advanced Java 8 CompletableFuture Features (Part 3)
Overview of Advanced Java 8 CompletableFuture Features (Part 3) Douglas C. Schmidt d.schmidt@vanderbilt.edu www.dre.vanderbilt.edu/~schmidt Professor of Computer Science Institute for Software Integrated
More informationJava Barrier Synchronizers: CyclicBarrier (Part 1)
Java Barrier Synchronizers: CyclicBarrier (Part 1) Douglas C. Schmidt d.schmidt@vanderbilt.edu www.dre.vanderbilt.edu/~schmidt Institute for Software Integrated Systems Vanderbilt University Nashville,
More informationOverview of Java s Support for Polymorphism
Overview of Java s Support for Polymorphism Douglas C. Schmidt d.schmidt@vanderbilt.edu www.dre.vanderbilt.edu/~schmidt Professor of Computer Science Institute for Software Integrated Systems Vanderbilt
More informationExternal vs. Internal Iteration in Java 8
External vs. Internal Iteration in Java 8 Douglas C. Schmidt d.schmidt@vanderbilt.edu www.dre.vanderbilt.edu/~schmidt Professor of Computer Science Institute for Software Integrated Systems Vanderbilt
More informationOverview of Java 8 Parallel Streams (Part 1)
Overview of Java 8 Parallel s (Part 1) Douglas C. Schmidt d.schmidt@vanderbilt.edu www.dre.vanderbilt.edu/~schmidt Professor of Computer Science Institute for Software Integrated Systems Vanderbilt University
More informationOverview of Patterns: Introduction
: Introduction d.schmidt@vanderbilt.edu www.dre.vanderbilt.edu/~schmidt Professor of Computer Science Institute for Software Integrated Systems Vanderbilt University Nashville, Tennessee, USA Introduction
More informationThe Java FutureTask. Douglas C. Schmidt
The Java FutureTask Douglas C. Schmidt d.schmidt@vanderbilt.edu www.dre.vanderbilt.edu/~schmidt Institute for Software Integrated Systems Vanderbilt University Nashville, Tennessee, USA Learning Objectives
More informationOverview of Advanced Java 8 CompletableFuture Features (Part 2)
Overview of Advanced Java 8 CompletableFuture Features (Part 2) Douglas C. Schmidt d.schmidt@vanderbilt.edu www.dre.vanderbilt.edu/~schmidt Professor of Computer Science Institute for Software Integrated
More informationType of Classes Nested Classes Inner Classes Local and Anonymous Inner Classes
Java CORE JAVA Core Java Programing (Course Duration: 40 Hours) Introduction to Java What is Java? Why should we use Java? Java Platform Architecture Java Virtual Machine Java Runtime Environment A Simple
More informationPATTERN-ORIENTED SOFTWARE ARCHITECTURE
PATTERN-ORIENTED SOFTWARE ARCHITECTURE A Pattern Language for Distributed Computing Volume 4 Frank Buschmann, Siemens, Munich, Germany Kevlin Henney, Curbralan, Bristol, UK Douglas C. Schmidt, Vanderbilt
More informationProduced by. Design Patterns. MSc in Computer Science. Eamonn de Leastar
Design Patterns MSc in Computer Science Produced by Eamonn de Leastar (edeleastar@wit.ie)! Department of Computing, Maths & Physics Waterford Institute of Technology http://www.wit.ie http://elearning.wit.ie
More informationANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL I)
ANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL I) Lecture 3: Android Life Cycle and Permission Entire Lifetime An activity begins its lifecycle when entering the oncreate() state If not interrupted
More informationJava 8 Parallel Stream Internals (Part 2)
Java 8 Parallel Stream Internals (Part 2) Douglas C. Schmidt d.schmidt@vanderbilt.edu www.dre.vanderbilt.edu/~schmidt Professor of Computer Science Institute for Software Integrated Systems Vanderbilt
More informationOverview of Activities
d.schmidt@vanderbilt.edu www.dre.vanderbilt.edu/~schmidt Institute for Software Integrated Systems Vanderbilt University Nashville, Tennessee, USA CS 282 Principles of Operating Systems II Systems Programming
More informationANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL I)
ANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL I) Lecture 3: Android Life Cycle and Permission Android Lifecycle An activity begins its lifecycle when entering the oncreate() state If not
More informationLecture 19 GUI Events
CSE 331 Software Design and Implementation Lecture 19 GUI Events The plan User events and callbacks Event objects Event listeners Registering listeners to handle events Anonymous inner classes Proper interaction
More informationCSE 331 Software Design and Implementation. Lecture 19 GUI Events
CSE 331 Software Design and Implementation Lecture 19 GUI Events Leah Perlmutter / Summer 2018 Announcements Announcements Quiz 7 due Thursday 8/9 Homework 8 due Thursday 8/9 HW8 has a regression testing
More informationCSE 331 Software Design & Implementation
CSE 331 Software Design & Implementation Hal Perkins Spring 2017 GUI Event-Driven Programming 1 The plan User events and callbacks Event objects Event listeners Registering listeners to handle events Anonymous
More informationAndroid Services & Local IPC: Overview of Programming Bound Services
: Overview of Programming Bound Services d.schmidt@vanderbilt.edu www.dre.vanderbilt.edu/~schmidt Professor of Computer Science Institute for Software Integrated Systems Vanderbilt University Nashville,
More informationA Case Study of Gang of Four (GoF) Patterns : Part 7
A Case Study of Gang of Four (GoF) Patterns : Part 7 d.schmidt@vanderbilt.edu www.dre.vanderbilt.edu/~schmidt Professor of Computer Science Institute for Software Integrated Systems Vanderbilt University
More informationJS Event Loop, Promises, Async Await etc. Slava Kim
JS Event Loop, Promises, Async Await etc Slava Kim Synchronous Happens consecutively, one after another Asynchronous Happens later at some point in time Parallelism vs Concurrency What are those????
More informationServices. service: A background task used by an app.
CS 193A Services This document is copyright (C) Marty Stepp and Stanford Computer Science. Licensed under Creative Commons Attribution 2.5 License. All rights reserved. Services service: A background task
More informationCS 370 Android Basics D R. M I C H A E L J. R E A L E F A L L
CS 370 Android Basics D R. M I C H A E L J. R E A L E F A L L 2 0 1 5 Activity Basics Manifest File AndroidManifest.xml Central configuration of Android application Defines: Name of application Icon for
More informationMultithreaded Programming Part II. CSE 219 Stony Brook University, Department of Computer Science
Multithreaded Programming Part II CSE 219 Stony Brook University, Thread Scheduling In a Java application, main is a thread on its own Once multiple threads are made Runnable the thread scheduler of the
More informationCS140 Operating Systems and Systems Programming Midterm Exam
CS140 Operating Systems and Systems Programming Midterm Exam October 31 st, 2003 (Total time = 50 minutes, Total Points = 50) Name: (please print) In recognition of and in the spirit of the Stanford University
More informationCOPYRIGHTED MATERIAL. Table of Contents. Foreword... xv. About This Book... xvii. About The Authors... xxiii. Guide To The Reader...
Table of Contents Foreword..................... xv About This Book... xvii About The Authors............... xxiii Guide To The Reader.............. xxvii Part I Some Concepts.................. 1 1 On Patterns
More informationPROCESSES AND THREADS THREADING MODELS. CS124 Operating Systems Winter , Lecture 8
PROCESSES AND THREADS THREADING MODELS CS124 Operating Systems Winter 2016-2017, Lecture 8 2 Processes and Threads As previously described, processes have one sequential thread of execution Increasingly,
More informationApplication Fundamentals
Application Fundamentals CS 2046 Mobile Application Development Fall 2010 Announcements CMS is up If you did not get an email regarding this, see me after class or send me an email. Still working on room
More informationThreads Questions Important Questions
Threads Questions Important Questions https://dzone.com/articles/threads-top-80-interview https://www.journaldev.com/1162/java-multithreading-concurrency-interviewquestions-answers https://www.javatpoint.com/java-multithreading-interview-questions
More informationMulti-Screen Online Multiplayer Game for an Android Device
COMP 4905 Honours Project Multi-Screen Online Multiplayer Game for an Android Device Author: Nicholas Tierney Supervised by: Dr. Tony White School of Computer Science Carleton University Ottawa, Canada
More informationEfficient Android Threading
.... - J.', ' < '.. Efficient Android Threading Anders Göransson Beijing Cambridge Farnham Köln Sebastopol Tokyo O'REILLY Table of Contents Preface xi 1. Android Components and the Need for Multiprocessing
More informationObject-Oriented Concepts and Design Principles
Object-Oriented Concepts and Design Principles Signature Specifying an object operation or method involves declaring its name, the objects it takes as parameters and its return value. Known as an operation
More informationIntroduction to Concurrent Software Systems. CSCI 5828: Foundations of Software Engineering Lecture 08 09/17/2015
Introduction to Concurrent Software Systems CSCI 5828: Foundations of Software Engineering Lecture 08 09/17/2015 1 Goals Present an overview of concurrency in software systems Review the benefits and challenges
More informationLecture 6: Android XML, Inversion of Control, Timers (Handlers), Activity
1 / 31 Lecture 6: Android XML, Inversion of Control, Timers (Handlers), Activity Engineering Design with Embedded Systems Patrick Lam University of Waterloo January 18, 2013 2 / 31 Housekeeping: Tutorials
More informationMultithreading and Interactive Programs
Multithreading and Interactive Programs CS160: User Interfaces John Canny. This time Multithreading for interactivity need and risks Some design patterns for multithreaded programs Debugging multithreaded
More informationLinguistic Symbiosis between Actors and Threads
Linguistic Symbiosis between s and Threads Tom Van Cutsem Stijn Mostinckx Wolfgang De Meuter Programming Technology Lab Vrije Universiteit Brussel Brussels, Belgium International Conference on Dynamic
More informationIntroduction to Concurrent Software Systems. CSCI 5828: Foundations of Software Engineering Lecture 12 09/29/2016
Introduction to Concurrent Software Systems CSCI 5828: Foundations of Software Engineering Lecture 12 09/29/2016 1 Goals Present an overview of concurrency in software systems Review the benefits and challenges
More informationMTAT Enterprise System Integration. Lecture 2: Middleware & Web Services
MTAT.03.229 Enterprise System Integration Lecture 2: Middleware & Web Services Luciano García-Bañuelos Slides by Prof. M. Dumas Overall view 2 Enterprise Java 2 Entity classes (Data layer) 3 Enterprise
More informationCS 351 Design of Large Programs Threads and Concurrency
CS 351 Design of Large Programs Threads and Concurrency Brooke Chenoweth University of New Mexico Spring 2018 Concurrency in Java Java has basic concurrency support built into the language. Also has high-level
More informationLecture 8: February 19
CMPSCI 677 Operating Systems Spring 2013 Lecture 8: February 19 Lecturer: Prashant Shenoy Scribe: Siddharth Gupta 8.1 Server Architecture Design of the server architecture is important for efficient and
More informationCSE 331 Software Design & Implementation
CSE 331 Software Design & Implementation Kevin Zatloukal Summer 2017 Java Graphics and GUIs (Based on slides by Mike Ernst, Dan Grossman, David Notkin, Hal Perkins, Zach Tatlock) Review: how to create
More informationOverview of Frameworks: Part 3
: Part 3 d.schmidt@vanderbilt.edu www.dre.vanderbilt.edu/~schmidt Institute for Software Integrated Systems Vanderbilt University Nashville, Tennessee, USA CS 282 Principles of Operating Systems II Systems
More informationProgramming in Android. Nick Bopp
Programming in Android Nick Bopp nbopp@usc.edu Types of Classes Activity This is the main Android class that you will be using. These are actively displayed on the screen and allow for user interaction.
More informationIEMS 5722 Mobile Network Programming and Distributed Server Architecture
Department of Information Engineering, CUHK MScIE 2 nd Semester, 2016/17 IEMS 5722 Mobile Network Programming and Distributed Server Architecture Lecture 1 Course Introduction Lecturer: Albert C. M. Au
More informationEmbedded Systems Programming - PA8001
Embedded Systems Programming - PA8001 http://bit.ly/15mmqf7 Lecture 5 Mohammad Mousavi m.r.mousavi@hh.se Center for Research on Embedded Systems School of Information Science, Computer and Electrical Engineering
More informationOperating Systems: Internals and Design Principles. Chapter 4 Threads Seventh Edition By William Stallings
Operating Systems: Internals and Design Principles Chapter 4 Threads Seventh Edition By William Stallings Operating Systems: Internals and Design Principles The basic idea is that the several components
More informationAn Async Primer. By Bill Wagner August Introduction
An Async Primer By Bill Wagner August 2012 Introduction The C# 5.0 release might seem small, given that the single major feature is the addition of async / await keywords to support asynchronous programming.
More informationSSC - Concurrency and Multi-threading Java multithreading programming - Synchronisation (II)
SSC - Concurrency and Multi-threading Java multithreading programming - Synchronisation (II) Shan He School for Computational Science University of Birmingham Module 06-19321: SSC Outline Outline of Topics
More informationBuilding Applications with ArcGIS Runtime SDK for Android Part II. Will Crick Dan O Neill
Building Applications with ArcGIS Runtime SDK for Android Part II Will Crick Dan O Neill Agenda Intro Connected editing summary Offline capabilities - Local features - Geometry Engine Platform integration
More informationCIS233J Java Programming II. Threads
CIS233J Java Programming II Threads Introduction The purpose of this document is to introduce the basic concepts about threads (also know as concurrency.) Definition of a Thread A thread is a single sequential
More informationCPS221 Lecture: Threads
Objectives CPS221 Lecture: Threads 1. To introduce threads in the context of processes 2. To introduce UML Activity Diagrams last revised 9/5/12 Materials: 1. Diagram showing state of memory for a process
More informationGrand Central Dispatch and NSOperation. CSCI 5828: Foundations of Software Engineering Lecture 28 12/03/2015
Grand Central Dispatch and NSOperation CSCI 5828: Foundations of Software Engineering Lecture 28 12/03/2015 1 Credit Where Credit Is Due Most of the examples in this lecture were inspired by example code
More informationYi Shi Fall 2017 Xi an Jiaotong University
Threads Yi Shi Fall 2017 Xi an Jiaotong University Goals for Today Case for Threads Thread details Case for Parallelism main() read_data() for(all data) compute(); write_data(); endfor main() read_data()
More informationOutline. Admin. Example: TipCalc. Android: Event Handler Blocking, Android Inter-Thread, Process Communications. Recap: Android UI App Basic Concepts
Outline Android: Event Handler Blocking, Android Inter-Thread, Process Communications 10/11/2012 Admin Android Basic concepts Activity, View, External Resources, Listener Inter-thread communications Handler,
More informationComputation Abstractions. Processes vs. Threads. So, What Is a Thread? CMSC 433 Programming Language Technologies and Paradigms Spring 2007
CMSC 433 Programming Language Technologies and Paradigms Spring 2007 Threads and Synchronization May 8, 2007 Computation Abstractions t1 t1 t4 t2 t1 t2 t5 t3 p1 p2 p3 p4 CPU 1 CPU 2 A computer Processes
More informationTishik Int. University / College of Science / IT Dept. This Course based mainly on online sources ADVANCED MOBILE APPLICATIONS / Spring 1
ADVANCED MOBILE APPLICATIONS / 2018-2019 Spring Tishik Int. University / College of Science / IT Dept. Presented By: Mohammad Salim Al-Othman For 4 th Grade Students This Course based mainly on online
More informationCS533 Concepts of Operating Systems. Jonathan Walpole
CS533 Concepts of Operating Systems Jonathan Walpole Overview Background Criticism of Threads Defense of Threads Compiler Support for Threads Evaluation Conclusion Background: Events Small, static number
More informationConcurrency Analysis of Asynchronous APIs
Concurrency Analysis of Asynchronous APIs Anirudh Santhiar and Aditya Kanade April 2, 2016 Computer Science and Automation, IISc Introduction Asynchronous Programming Model1 A way to organize programs
More informationLab 1: Getting Started With Android Programming
Islamic University of Gaza Faculty of Engineering Computer Engineering Dept. Eng. Jehad Aldahdooh Mobile Computing Android Lab Lab 1: Getting Started With Android Programming To create a new Android Project
More informationSwift 5, ABI Stability and
Swift 5, ABI Stability and Concurrency @phillfarrugia Important Documents Concurrency Manifesto by Chris Lattner https: /gist.github.com/lattner/ 31ed37682ef1576b16bca1432ea9f782 Kicking off Concurrency
More informationSmall talk with the UI thread. Landon Cox March 9, 2017
Small talk with the UI thread Landon Cox March 9, 2017 Android threads Thread: a sequence of executing instructions Every app has a main thread Processes UI events (taps, swipes, etc.) Updates the UI Apps
More informationModule dependences and decoupling (Events, listeners, callbacks)
Module dependences and decoupling (Events, listeners, callbacks) CSE 331 University of Washington Michael Ernst The limits of scaling What prevents us from building huge, intricate structures that work
More informationJAVA CONCURRENCY FRAMEWORK. Kaushik Kanetkar
JAVA CONCURRENCY FRAMEWORK Kaushik Kanetkar Old days One CPU, executing one single program at a time No overlap of work/processes Lots of slack time CPU not completely utilized What is Concurrency Concurrency
More informationCMSC 433 Programming Language Technologies and Paradigms. Concurrency
CMSC 433 Programming Language Technologies and Paradigms Concurrency What is Concurrency? Simple definition Sequential programs have one thread of control Concurrent programs have many Concurrency vs.
More informationJava Swing Introduction
Course Name: Advanced Java Lecture 18 Topics to be covered Java Swing Introduction What is Java Swing? Part of the Java Foundation Classes (JFC) Provides a rich set of GUI components Used to create a Java
More informationJava s Implementation of Concurrency, and how to use it in our applications.
Java s Implementation of Concurrency, and how to use it in our applications. 1 An application running on a single CPU often appears to perform many tasks at the same time. For example, a streaming audio/video
More informationCS 160: Interactive Programming
CS 160: Interactive Programming Professor John Canny 3/8/2006 1 Outline Callbacks and Delegates Multi-threaded programming Model-view controller 3/8/2006 2 Callbacks Your code Myclass data method1 method2
More informationStatic Analysis for Android: GUIs, Callbacks, and Beyond
Static Analysis for Android: GUIs, Callbacks, and Beyond Atanas (Nasko) Rountev Joint work with Dacong Yan Shengqian Yang Haowei Wu Yan Wang Hailong Zhang Ohio State University PRESTO: Program Analyses
More informationJava Thread Programming By Paul Hyde
Java Thread Programming By Paul Hyde Buy, download and read Java Thread Programming ebook online in PDF format for iphone, ipad, Android, Computer and Mobile readers. Author: Paul Hyde. ISBN: 9780768662085.
More informationLecture 4: Threads; weaving control flow
Lecture 4: Threads; weaving control flow CSE 120: Principles of Operating Systems Alex C. Snoeren HW 1 Due NOW Announcements Homework #1 due now Project 0 due tonight Project groups Please send project
More informationTHREADS & CONCURRENCY
27/04/2018 Sorry for the delay in getting slides for today 2 Another reason for the delay: Yesterday: 63 posts on the course Piazza yesterday. A7: If you received 100 for correctness (perhaps minus a late
More informationAndroid App Development
Android App Development Outline Introduction Android Fundamentals Android Studio Tutorials Introduction What is Android? A software platform and operating system for mobile devices Based on the Linux kernel
More informationChris Guzman. Developer chris-guzman.com
WebSocket to me! Chris Guzman Developer Advocate @ Nexmo @speaktochris chris-guzman.com Before... Before... (A few years ago) HTTP Polling TCP/IP Sockets WebSockets /webˈsäkəts/ bi-directional realtime
More informationCSE 120 Principles of Operating Systems
CSE 120 Principles of Operating Systems Fall 2000 Lecture 5: Threads Geoffrey M. Voelker Processes Recall that a process includes many things An address space (defining all the code and data pages) OS
More informationWindows and Events. created originally by Brian Bailey
Windows and Events created originally by Brian Bailey Announcements Review next time Midterm next Friday UI Architecture Applications UI Builders and Runtimes Frameworks Toolkits Windowing System Operating
More informationLesson 1 Key-Terms Meanings: Web Connectivity of Devices and Devices Network
Lesson 1 Key-Terms Meanings: Web Connectivity of Devices and Devices Network 1 Application Application: A software (S/W) for an application, such as, creating and sending an SMS, measuring and sending
More informationWPF and MVVM Study Guides
1. Introduction to WPF WPF and MVVM Study Guides https://msdn.microsoft.com/en-us/library/mt149842.aspx 2. Walkthrough: My First WPF Desktop Application https://msdn.microsoft.com/en-us/library/ms752299(v=vs.110).aspx
More informationCS 450 Operating System Week 4 Lecture Notes
CS 450 Operating System Week 4 Lecture Notes Reading: Operating System Concepts (7 th Edition) - Silberschatz, Galvin, Gagne Chapter 5 - Pages 129 147 Objectives: 1. Explain the main Objective of Threads
More informationTopics in Parallel and Distributed Computing: Introducing Algorithms, Programming, and Performance within Undergraduate Curricula
Topics in Parallel and Distributed Computing: Introducing Algorithms, Programming, and Performance within Undergraduate Curricula Chapter 9 Managing Concurrency in Mobile User Interfaces with Examples
More informationProcess Concepts. CSC400 - Operating Systems. 3. Process Concepts. J. Sumey
CSC400 - Operating Systems 3. Process Concepts J. Sumey Overview Concurrency Processes & Process States Process Accounting Interrupts & Interrupt Processing Interprocess Communication CSC400 - Process
More informationHCA Tech Note 120. Configuring the Control UI Home Page. Option 1: HCA constructs the home page
Configuring the Control UI Home Page HCA contains two different user interfaces: One interface called the Development UI - where all design elements and tools are available and you can make changes, and
More informationBackground: Operating Systems
Background: Operating Systems Brad Karp UCL Computer Science CS GZ03 / M030 9 th October 2015 Outline Goals of an operating system Sketch of UNIX User processes, kernel Process-kernel communication Waiting
More informationBSc ( Hons) Computer Science with Network Security. Examinations for / Semester 2
BSc ( Hons) Computer Science with Network Security Cohort: BCNS/16B/FT Examinations for 2017 2018 / Semester 2 Resit Examinations for BCNS/15B/FT & BCNS/16A/FT MODULE: NETWORK PROGRAMMING MODULE CODE:
More informationMobile Development Workshop DAY 2: INTRODUCTION TO JAVA
Mobile Development Workshop DAY 2: INTRODUCTION TO JAVA Overview Morning session For loops Strings and collections Graphical User Interfaces Recap Last time we covered Java the programming language and
More informationToday s Topics. u Thread implementation. l Non-preemptive versus preemptive threads. l Kernel vs. user threads
Today s Topics COS 318: Operating Systems Implementing Threads u Thread implementation l Non-preemptive versus preemptive threads l Kernel vs. user threads Jaswinder Pal Singh and a Fabulous Course Staff
More informationOverview of Java 8 Functional Interfaces
Overview of Java 8 Functional Interfaces Douglas C. Schmidt d.schmidt@vanderbilt.edu www.dre.vanderbilt.edu/~schmidt Professor of Computer Science Institute for Software Integrated Systems Vanderbilt University
More informationCSE 120 Principles of Operating Systems
CSE 120 Principles of Operating Systems Fall 2015 Lecture 4: Threads Geoffrey M. Voelker Announcements Project 0 due Project 1 out October 6, 2015 CSE 120 Lecture 4 Threads 2 Processes Recall that a process
More information