081017slides_handouts

081017slides_handouts - 1 UVa CS205 Engineering Software...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 1 UVa CS205 Engineering Software 2008 Concurrency UVa CS205 Engineering Software 2008 PS5 & Project PS5: Questions? Part II done in teams of 2 Teams have been determined Building up to a PDES Project (after PS5) Teams of 1-4 Build some useful software using principles and methods from cs205 You can choose the language but you have to follow cs205 design and implementation principles UVa CS205 Engineering Software 2008 Buzzword Description A simple, object-oriented, distributed, interpreted, robust, secure, architecture neutral, portable, high- performance , multithreaded, and dynamic language. [Sun95] from Class 2... UVa CS205 Engineering Software 2008 Multiple Threads Store Instruction Streams Shared Data 2 UVa CS205 Engineering Software 2008 A computer can only do one instruction at a time, why would we want to program pretending it can do many things at once? UVa CS205 Engineering Software 2008 Concurrent Programming Some problems are clearer to program concurrently: Modularity Dont 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 arent sequential UVa CS205 Engineering Software 2008 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 } UVa CS205 Engineering Software 2008 Making a Thread // 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(); } public class Thread implements Runnable { public Thread (Runnable target) public void start () many other methods } What do you know about SimObject type? 3 UVa CS205 Engineering Software 2008 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....
View Full Document

This note was uploaded on 04/05/2010 for the course CS 150 taught by Professor Humphreys,g during the Spring '08 term at UVA.

Page1 / 7

081017slides_handouts - 1 UVa CS205 Engineering Software...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online