SurfaceView.

Slides:



Advertisements
Similar presentations
Cannon Game 1 Fall 2014 CS7020: Game Design and Development.
Advertisements

Algorithm Programming Concurrent Programming in Java Bar-Ilan University תשס"ח Moshe Fresko.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved L19 (Chapter 24) Multithreading.
CSE S. Tanimoto Java Threads 1 Java Threads (Outline) Motivation The class Thread Example program: ThreadRace The Runnable interface Example: Clock.
Software Engineering Oct-01 #11: All About Threads Phil Gross.
CS220 Software Development Lecture: Multi-threading A. O’Riordan, 2009.
Definitions Process – An executing program
Multithreading in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Java Threads CS Introduction to Operating Systems.
50.003: Elements of Software Construction Week 5 Basics of Threads.
Parallel Processing (CS526) Spring 2012(Week 8).  Thread Status.  Synchronization in Shared Memory Programming(Java threads ) ◦ Locks ◦ Barriars.
A Bridge to Your First Computer Science Course Prof. H.E. Dunsmore Concurrent Programming Threads Synchronization.
University of Sunderland Java Threading, Mutex and Synchronisation Lecture 02 COMM86 Concurrent and Distributed Software Systems.
Threads. Overview Problem Multiple tasks for computer Draw & display images on screen Check keyboard & mouse input Send & receive data on network Read.
Multi-Threaded Application CSNB534 Asma Shakil. Overview Software applications employ a strategy called multi- threaded programming to split tasks into.
Quick overview of threads in Java Babak Esfandiari (extracted from Qusay Mahmoud’s slides)
Multithreading in Java Project of COCS 513 By Wei Li December, 2000.
Today’s Agenda  Quick Review  Finish Java Threads  The CS Problem Advanced Topics in Software Engineering 1.
Java Threads Representation and Management of Data on the Internet.
Threads Concurrency in Java. What is mult-tasking? Doing more than one task.
111 © 2002, Cisco Systems, Inc. All rights reserved.
Threads in Java. Processes and Threads Processes –A process has a self-contained execution environment. –Has complete set of runtime resources including.
1 Web Based Programming Section 8 James King 12 August 2003.
Concurrent Programming and Threads Threads Blocking a User Interface.
C20: Threads see also: ThreadedBallWorld, DropTest, Tetris source examples Not covered: advanced stuff like notify/notifyAll.
Multithreading in Java Sameer Singh Chauhan Lecturer, I. T. Dept., SVIT, Vasad.
Introduction to Threads Session 01 Java Simplified / Session 14 / 2 of 28 Objectives Define a thread Define multithreading List benefits of multithreading.
Multithreading Chapter Introduction Consider ability of _____________ to multitask –Breathing, heartbeat, chew gum, walk … In many situations we.
Threading and Concurrency COM379T John Murray –
15.1 Threads and Multi- threading Understanding threads and multi-threading In general, modern computers perform one task at a time It is often.
Concurrency Control 1 Fall 2014 CS7020: Game Design and Development.
Concurrent Computing CSCI 201L Jeffrey Miller, Ph.D. HTTP :// WWW - SCF. USC. EDU /~ CSCI 201 USC CSCI 201L.
Multi-Threading in Java
Multithreaded programming  Java provides built-in support for multithreaded programming. A multithreaded program contains two or more parts that can run.
Multithreading. Multithreaded Programming A multithreaded program contains two or more parts that can run concurrently. Each part of such a program is.
Parallel Processing (CS526) Spring 2012(Week 8).  Shared Memory Architecture  Shared Memory Programming & PLs  Java Threads  Preparing the Environment.
1 OS Review Processes and Threads Chi Zhang
Peyman Dodangeh Sharif University of Technology Fall 2014.
Java Threads DBI – Representation and Management of Data on the Internet.
Multithreading & Synchronized Algoritma Pemrograman 3 Sistem Komputer – S1 Universitas Gunadarma 1.
Multithreading. Multitasking The multitasking is the ability of single processor to perform more than one operation at the same time Once systems allowed.
Threads b A thread is a flow of control in a program. b The Java Virtual Machine allows an application to have multiple threads of execution running concurrently.
L6: Threads “the future is parallel” COMP206, Geoff Holmes and Bernhard Pfahringer.
1 Threads in Java Jingdi Wang. 2 Introduction A thread is a single sequence of execution within a program Multithreading involves multiple threads of.
Concurrency in Java MD. ANISUR RAHMAN. slide 2 Concurrency  Multiprogramming  Single processor runs several programs at the same time  Each program.
Concurrent Programming in Java Based on Notes by J. Johns (based on Java in a Nutshell, Learning Java) Also Java Tutorial, Concurrent Programming in Java.
CS203 Programming with Data Structures Introduction to Threads and Synchronization California State University, Los Angeles.
Multithreading / Concurrency
Multithreading Lec 23.
Java Multithreading.
Lecture 9 Object Oriented Programming Using Java
Multithreaded Programming in Java
Threads Chate Patanothai.
Definitions Concurrent program – Program that executes multiple instructions at the same time. Process – An executing program (the running JVM for Java.
Advanced Programming Behnam Hatami Fall 2017.
Advanced Programming in Java
Cs561 Presenter: QIAOQIAO CHEN Spring 2012
Multithreading.
Multithreading 2 Lec 24.
Multithreaded Programming
Java Threads (Outline)
Java Threads (Outline)
برنامه‌نویسی چندنخی Multi-Thread Programming
21 Threads.
Java Thread.
Multithreading in java.
Threads and Multithreading
Representation and Management of Data on the Internet
Lecture 19 Threads CSE /6/2019.
Java Chapter 3 (Estifanos Tilahun Mihret--Tech with Estif)
Presentation transcript:

SurfaceView

Multitasking and Multithreading refers to a computer's ability to perform multiple jobs concurrently more than one program are running concurrently, e.g., UNIX Multithreading: A thread is a single sequence of execution within a program refers to multiple threads of control within a single program each program can run multiple threads of control within it, e.g., Web Browser The Open Systems Interconnection (OSI) model is a product of the Open Systems Interconnection effort at the International Organization for Standardization (ISO).

Concurrency vs. Parallelism CPU CPU1 CPU2

Threads and Processes CPU Process 1 Process 2 Process 3 Process 4 main run GC

Creating Threads There are two ways to create our own Thread object Extend the Thread class and instantiating a new object of that class Implementing the Runnable interface In both cases the run() method should be implemented

Extending Thread public class ThreadExample extends Thread { public void run () { for (int i = 1; i <= 100; i++) { System.out.println(“---”); }

Thread Methods void start() void run() void stop() (deprecated) Creates a new thread and makes it runnable This method can be called only once void run() The new thread begins its life inside this method void stop() (deprecated) The thread is being terminated

Thread Methods void yield() void sleep(int m) or sleep(int m, int n) Causes the currently executing thread object to temporarily pause and allow other threads to execute Allow only threads of the same priority to run void sleep(int m) or sleep(int m, int n)   The thread sleeps for m milliseconds, plus n nanoseconds

Implementing Runnable public class RunnableExample implements Runnable { public void run () { for (int i = 1; i <= 100; i++) { System.out.println (“***”); }

A Runnable Object When running the Runnable object, a Thread object is created from the Runnable object The Thread object’s run() method calls the Runnable object’s run() method Allows threads to run inside any object, regardless of inheritance

Thread State Diagram Alive Running new Thread(); while (…) { … } Runnable Dead Thread thread.start(); run() method returns Blocked Object.wait() Thread.sleep() blocking IO call waiting on a monitor Fall 2014 CS7020: Game Design and Development

SurfaceView A subclass of View Any thread can draw SurfaceHolder can manipulate a SurfaceView. SurfaceHolder.Callback contains methods when the SurfaceView is created, changed or destroyed. Usually, an app’s user interface must be performed in the main GUI thread of execution.

SurfaceHolder Methods lockCanvas: obtain the canvas for drawing on the SurfaceView synchronized block: only one thread at a time can draw to a SurfaceView unlockCanvasAndPost: post the change and release the canvas

Display Dialog A dialog must be displayed from the main GUI thread Call activity method runOnUiThread