Concurring Concurrently

Slides:



Advertisements
Similar presentations
Threads, SMP, and Microkernels
Advertisements

David Evans CS201j: Engineering Software University of Virginia Computer Science Lecture 13: Concurring Concurrently.
David Evans CS201j: Engineering Software University of Virginia Computer Science Lecture 16: Concurrent Programming.
Java Overview February 4, /4/2004 Assignments Due – Homework 1 Due – Reading and Warmup questions Project 1 – Basic Networking.
ELEC6200, Fall 07, Oct 29 Westrom: Virtual Machines 1 Kenneth Westrom ELEC-6620.
Introduction to Java Programming Language Junji Zhi University of Toronto 1.
Threading in Java – a Tutorial QMUL IEEE SB. Why Threading When we need to run two tasks concurrently So multiple parts (>=2) of a program can run simultaneously.
50.003: Elements of Software Construction Week 5 Basics of Threads.
What is Concurrent Programming? Maram Bani Younes.
1 Testing Concurrent Programs Why Test?  Eliminate bugs?  Software Engineering vs Computer Science perspectives What properties are we testing for? 
A Bridge to Your First Computer Science Course Prof. H.E. Dunsmore Concurrent Programming Threads Synchronization.
Cs205: engineering software university of virginia fall 2006 Data Abstraction David Evans
Multithreading in Java Project of COCS 513 By Wei Li December, 2000.
Class 14: Object-Oriented Programming Fall 2010 University of Virginia David Evans cs2220: Engineering Software.
Introduction and Features of Java. What is java? Developed by Sun Microsystems (James Gosling) A general-purpose object-oriented language Based on C/C++
David Evans CS201j: Engineering Software University of Virginia Computer Science Lecture 12: Subtyping Rules What’s the.
We will talking about story of JAVA language. By Kristsada Songpartom.
Copyright © Mohamed Nuzrath Java Programming :: Syllabus & Chapters :: Prepared & Presented By :: Mohamed Nuzrath [ Major In Programming ] NCC Programme.
Cs205: engineering software university of virginia fall 2006 Introducing Java David Evans Don’t forget to your registration.
Concurrency Control 1 Fall 2014 CS7020: Game Design and Development.
1 The JAVA Language Object Oriented Technology Mithani Binjan M.
Cs2220: Engineering Software Class 13: Behavioral Subtyping Fall 2010 University of Virginia David Evans.
Multithreaded Programming in Java David Meredith Aalborg University.
Design and implementation Chapter 7 – Lecture 1. Design and implementation Software design and implementation is the stage in the software engineering.
Cs205: engineering software university of virginia fall 2006 Programming Exceptionally David Evans
Concurrent Programming Acknowledgements: Some slides adapted from David Evans, U. Virginia.
Concurrency in Java MD. ANISUR RAHMAN. slide 2 Concurrency  Multiprogramming  Single processor runs several programs at the same time  Each program.
David Evans CS201J: Engineering Software University of Virginia Computer Science Lecture 5: Implementing Data Abstractions.
Cs205: engineering software university of virginia fall 2006 David Evans Object-Oriented Programming.
1 Sections Java Virtual Machine and Byte Code Fundamentals of Java: AP Computer Science Essentials, 4th Edition Lambert / Osborne.
JAVA TRAINING IN NOIDA. Introduction to Java:  Java training in noida is a general-purpose computer programming language that is concurrent, class-based,
JAVA PROGRAMMING Buzzwords. Simple: Less complex syntax than C++ Not as easy to design as Visual Basic Small size of interpreter.
Sung-Dong Kim, Dept. of Computer Engineering, Hansung University Java - Introduction.
Object Oriented Programming in
Interpreted languages Jakub Yaghob
Done By: Ashlee Lizarraga Ricky Usher Jacinto Roches Eli Gomez
Chapter 1 Introduction to Computers, Programs, and Java
Chapter No. : 1 Introduction to Java.
PA1 Discussion.
CS216: Program and Data Representation
The Java Programming Language
Part 3 Design What does design mean in different fields?
Locking cs205: engineering software
ITEC324 Principle of CS III
Getting Started ARCS Lab..
Advanced Programming Fall 2017.
Lecture 15: Concurring Concurrently CS201j: Engineering Software
Threads, SMP, and Microkernels
Security in Java Real or Decaf? cs205: engineering software
CMPE 152: Compiler Design August 21 Class Meeting
Object Oriented Programming
Data Abstraction David Evans cs205: engineering software
What is Concurrent Programming?
Units with – James tedder
Lecture 4- Threads, SMP, and Microkernels
Units with – James tedder
Lecture 4: Data Abstraction CS201j: Engineering Software
What is Concurrent Programming?
Unit 1 Lab14 & Lab15.
(Computer fundamental Lab)
Java History, Editions, Version Features
By Rajanikanth B Overview Of Java By Rajanikanth B
COMPONENTS – WHY? Object-oriented source-level re-use of code requires same source code language. Object-oriented source-level re-use may require understanding.
David Evans Lecture 19: ||ism I don’t think we have found the right programming concepts for parallel computers yet.
Foundations and Definitions
Lecture 13: Subtyping Rules Killer Bear Climber
CMSC 202 Threads.
Outcome of the Lecture Upon completion of this lecture you will be able to understand Fundamentals and Characteristics of Java Language Basic Terminology.
Threads and concurrency / Safety
Presentation transcript:

Concurring Concurrently cs205: engineering software university of virginia fall 2006 Concurring Concurrently David Evans www.cs.virginia.edu/cs205

PS5 & Project PS5: Out Today Project (after PS5) Last part of it will be done in teams of 3 Team requests due by midnight tomorrow (or you will be assigned arbitrarily to a team) Build a distributed simulation Project (after PS5) Teams of 1-9 Build some useful software using principles and methods from cs205

Buzzword Description [Sun95] from Class 2... “A simple, object-oriented, distributed, interpreted, robust, secure, architecture neutral, portable, high-performance, multithreaded, and dynamic language.” [Sun95]

Multiple Threads Store Shared Data Instruction Streams

Our computer can only do one instruction at a time, why would we want to program pretending it can do many things at once?

Concurrent Programming Some problems are clearer to program concurrently: Modularity Don’t have to explicitly interleave code for different abstractions (especially: user interfaces) High-level interactions – synchronization, communication Modeling Closer map to real world problems: things in the real world aren’t sequential

Concurrency in Java public class Thread implements Runnable { // OVERVIEW: A thread is a thread of execution in a program. // The Java Virtual Machine allows an application to have // multiple threads of execution running concurrently. public Thread (Runnable target) // Creates a new Thread object that will run the target. public void start () // Starts a new thread of execution. … many other methods }

Making a Thread // from PS5 SimObject class: public class Thread implements Runnable { public Thread (Runnable target) public void start () … many other methods } // from PS5 SimObject class: final public void init(int x, int y, Grid grid) throws BadLocationException // REQUIRES: this is uninitialized // MODIFIES: this // EFFECTS: If x, y is not a valid location on grid, throws BadLocationException. // Otherwise, initializes the cell at row, col on grid with isPaused = true. { this.mx = x; this.my = y; this.grid = grid; this.isPaused = true; Thread thread = new Thread(this); thread.setPriority(Thread.MIN_PRIORITY); thread.start(); } What do you know about SimObject type?

Runnable public interface Runnable { public void run() When an object implementing interface Runnable is used to create a thread, starting the thread causes the object's run method to be called in that separately executing thread. The general contract of the method run is that it may take any action whatsoever. } So, to be a subtype of Runnable, SimObject must have a method void run () with any postconditions it wants.

Making a Runnable abstract public class SimObject implements Runnable { … public void run () // EFFECTS: Executes one turn by calling the // executeTurn method, and sleeps for a time // and repeats. { while (true) { executeTurn (); delay (TURN_DELAY + random.nextInt(TURN_RANDOM)); }

Actually… abstract public class SimObject implements Runnable { … public void run () // REQUIRES: this has been initialized // EFFECTS: Executes one turn by calling the // executeTurn method, and sleeps for a time // and repeats. { } Hint: PS5 question 1 – is it okay to add this requires clause?

Concurrency Making a concurrent Java program is easy: Make a subtype R of Runnable new Thread (new R ()).start () Making a concurrent Java program that behaves correctly is really, really hard!