Project. Threads. Plan for today. Before we begin. Thread. Thread. Minimum submission. Synchronization TSP. Thread synchronization. Any questions?
|
|
- Amber Richards
- 5 years ago
- Views:
Transcription
1 Project Threads Synchronization Minimum submission Deadline extended to tonight at midnight Early submitters 10 point bonus TSP Still due on Tuesday! Before we begin Plan for today Thread synchronization Any questions? Questions with threads? Thread A thread is a single sequential flow of control within a program Sometimes called: Execution context Lightweight process Thread A thread is not a program It cannot run on its own Runs within a program
2 Thread Thread States Multiple threads can be running at the same time within a single program The start() method places a thread in the ready state Ready The scheduler selects a thread and places it in the running state Waiting Running A thread that is waiting for I/O, was suspended, is sleeping, blocked, or otherwise is unable to do any more work is placed in the waiting state join() join () is NOT a static method Calling join() on a thread will make the caller wait until the thread is done join() public class WorkerThread extends Thread { private int result = 0; // Perform a complicated time consuming calculation // and store the answer in the variable result public static void main(string args[]) { WorkerThread t = new WorkerThread(); t.start(); try { t.join(); catch ( InterruptedException ex ) { System.out.println( result ); One possible solution
3 Another possible scenerio Critical section Critical section block of code that must be executed by at most 1 thread at a time. The updating of common in the last example (run method) would be considered a critical section. Java locks Every Java Object contains a lock that can be held by at most one thread at any given time Allows for mutually exclusive access to a sequence of code Obtain lock here Hold lock Release lock synchronized A thread can obtain the lock on a Java object by using the synchronized statement. Example with Java locks public class ConcAccess extends Thread { private static final Integer lock = new Integer (0); synchronized (lock) {
4 Bad Example with Java locks Threads and Locks private Integer lock; public ConcAcess () { lock = new Integer(0); synchronized (lock) { Questions? Java locks with this An object can choose to grab a lock to itself when running one of its methods public somemethod() { synchronized( this ) { Synchronized methods Declaring a method to be synchronized is a shorthand for grabbing the lock on this. public synchronized somemethod() { Is the same as public somemethod() { synchronized( this ) { Synchronized Static Methods Java also provides synchronized static methods. Before a synchronized static method is executed, the calling thread must first obtain the class lock. Since there is only one class lock, at most one thread can hold the lock for the class (object locks can be held by different threads locking on different instances of the class). Synchronization and Java Collections From HashSet javadoc: Note that this implementation is not synchronized. If multiple threads access a set concurrently, and at least one of the threads modifies the set, it must be synchronized externally. Meaning Different threads can manipulate the collection concurrently.
5 Wrapper Implementations Wrapper implementations add some functionality on top of what a collection offer Synchronization Unmodifiable Wrappers simply delegate all of their real work to a specified collection synchronization wrappers The synchronization wrappers, will make the Collection thread safe. It is imperative that the user manually synchronize on the returned set when iterating over it: Set s = Collections.synchronizedSet(new HashSet());... synchronized(s) { Iterator i = s.iterator(); // Must be in the block while (i.hasnext()) foo(i.next()); synchronization wrappers Synchronization public static Collection synchronizedcollection(collection c); public static Set synchronizedset(set s); public static List synchronizedlist(list list); public static Map synchronizedmap(map m); public static SortedSet synchronizedsortedset(sortedset s); public static SortedMap synchronizedsortedmap(sortedmap m); Questions? Let s go through some code.
Java Collections Framework reloaded
Java Collections Framework reloaded October 1, 2004 Java Collections - 2004-10-01 p. 1/23 Outline Interfaces Implementations Ordering Java 1.5 Java Collections - 2004-10-01 p. 2/23 Components Interfaces:
More informationLecture 6 Collections
Lecture 6 Collections Concept A collection is a data structure actually, an object to hold other objects, which let you store and organize objects in useful ways for efficient access Check out the java.util
More informationCMSC 132: Object-Oriented Programming II
CMSC 132: Object-Oriented Programming II Synchronization in Java Department of Computer Science University of Maryland, College Park Multithreading Overview Motivation & background Threads Creating Java
More informationIntroduction to Java Threads
Object-Oriented Programming Introduction to Java Threads RIT CS 1 "Concurrent" Execution Here s what could happen when you run this Java program and launch 3 instances on a single CPU architecture. The
More informationPrinciples of Software Construction: Concurrency, Part 2
Principles of Software Construction: Concurrency, Part 2 Josh Bloch Charlie Garrod School of Computer Science 1 Administrivia Homework 5a due now Homework 5 framework goals: Functionally correct Well documented
More informationProgramming in Parallel COMP755
Programming in Parallel COMP755 All games have morals; and the game of Snakes and Ladders captures, as no other activity can hope to do, the eternal truth that for every ladder you hope to climb, a snake
More informationJava Threads. COMP 585 Noteset #2 1
Java Threads The topic of threads overlaps the boundary between software development and operation systems. Words like process, task, and thread may mean different things depending on the author and the
More informationBasics of. Multithreading in Java
Basics of programming 3 Multithreading in Java Thread basics Motivation in most cases sequential (single threaded) applications are not adequate it s easier to decompose tasks into separate instruction
More informationAn Introduction to Programming with Java Threads Andrew Whitaker University of Washington 9/13/2006. Thread Creation
An Introduction to Programming with Java Threads Andrew Whitaker University of Washington 9/13/2006 This document provides a brief introduction to programming with threads in Java. I presume familiarity
More informationChair of Software Engineering. Java and C# in depth. Carlo A. Furia, Marco Piccioni, Bertrand Meyer. Java: concurrency
Chair of Software Engineering Carlo A. Furia, Marco Piccioni, Bertrand Meyer Java: concurrency Outline Java threads thread implementation sleep, interrupt, and join threads that return values Thread synchronization
More informationThreads and Parallelism in Java
Threads and Parallelism in Java Java is one of the few main stream programming languages to explicitly provide for user-programmed parallelism in the form of threads. A Java programmer may organize a program
More informationCOMP 346 WINTER Tutorial 2 SHARED DATA MANIPULATION AND SYNCHRONIZATION
COMP 346 WINTER 2018 1 Tutorial 2 SHARED DATA MANIPULATION AND SYNCHRONIZATION REVIEW - MULTITHREADING MODELS 2 Some operating system provide a combined user level thread and Kernel level thread facility.
More informationCS193k, Stanford Handout #8. Threads 3
CS193k, Stanford Handout #8 Spring, 2000-01 Nick Parlante Threads 3 t.join() Wait for finish We block until the receiver thread exits its run(). Use this to wait for another thread to finish. The current
More informationCMSC 132: Object-Oriented Programming II. Threads in Java
CMSC 132: Object-Oriented Programming II Threads in Java 1 Problem Multiple tasks for computer Draw & display images on screen Check keyboard & mouse input Send & receive data on network Read & write files
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 informationJAVA and J2EE UNIT - 4 Multithreaded Programming And Event Handling
JAVA and J2EE UNIT - 4 Multithreaded Programming And Event Handling Multithreaded Programming Topics Multi Threaded Programming What are threads? How to make the classes threadable; Extending threads;
More informationNote: Each loop has 5 iterations in the ThreeLoopTest program.
Lecture 23 Multithreading Introduction Multithreading is the ability to do multiple things at once with in the same application. It provides finer granularity of concurrency. A thread sometimes called
More informationSystem Programming. Practical Session 4: Threads and Concurrency / Safety
System Programming Practical Session 4: Threads and Concurrency / Safety Using Threads - All the computer programs you've seen so far were sequential only one thing was performed at any given time - Sometimes
More informationChapter 32 Multithreading and Parallel Programming
Chapter 32 Multithreading and Parallel Programming 1 Objectives To get an overview of multithreading ( 32.2). To develop task classes by implementing the Runnable interface ( 32.3). To create threads to
More informationJava Threads. Introduction to Java Threads
Java Threads Resources Java Threads by Scott Oaks & Henry Wong (O Reilly) API docs http://download.oracle.com/javase/6/docs/api/ java.lang.thread, java.lang.runnable java.lang.object, java.util.concurrent
More informationMultiple Inheritance. Computer object can be viewed as
Multiple Inheritance We have seen that a class may be derived from a given parent class. It is sometimes useful to allow a class to be derived from more than one parent, inheriting members of all parents.
More informationpublic class Shared0 { private static int x = 0, y = 0;
A race condition occurs anytime that the execution of one thread interferes with the desired behavior of another thread. What is the expected postcondition for the following bump() method? What should
More informationCS 556 Distributed Systems
CS 556 Distributed Systems Tutorial on 4 Oct 2002 Threads A thread is a lightweight process a single sequential flow of execution within a program Threads make possible the implementation of programs that
More informationLecture 9: Introduction to Monitors
COMP 150-CCP Concurrent Programming Lecture 9: Introduction to Monitors Dr. Richard S. Hall rickhall@cs.tufts.edu Concurrent programming February 14, 2008 Abstracting Locking Details Recall our discussion
More informationChair of Software Engineering. Java and C# in Depth. Prof. Dr. Bertrand Meyer. Exercise Session 8. Nadia Polikarpova
Chair of Software Engineering Java and C# in Depth Prof. Dr. Bertrand Meyer Exercise Session 8 Nadia Polikarpova Quiz 1: What is printed? (Java) class MyTask implements Runnable { «Everything is ok! public
More information04-Java Multithreading
04-Java Multithreading Join Google+ community http://goo.gl/u7qvs You can ask all your doubts, questions and queries by posting on this G+ community during/after webinar http://openandroidlearning.org
More informationMichele Van Dyne MUS 204B https://katie.mtech.edu/classes/csci136. Concurrency Issues
Michele Van Dyne MUS 204B mvandyne@mtech.edu https://katie.mtech.edu/classes/csci136 Concurrency Issues Multi-threaded programs Multiple simultaneous paths of execution Seemingly at once (single core)
More informationExercise Session Week 8
Chair of Software Engineering Java and C# in Depth Carlo A. Furia, Marco Piccioni, Bertrand Meyer Exercise Session Week 8 Java 8 release date Was early September 2013 Currently moved to March 2014 http://openjdk.java.net/projects/jdk8/milestones
More informationThreads Chate Patanothai
Threads Chate Patanothai Objectives Knowing thread: 3W1H Create separate threads Control the execution of a thread Communicate between threads Protect shared data C. Patanothai Threads 2 What are threads?
More informationReintroduction to Concurrency
Reintroduction to Concurrency The execution of a concurrent program consists of multiple processes active at the same time. 9/25/14 7 Dining philosophers problem Each philosopher spends some time thinking
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 informationOverview. CMSC 330: Organization of Programming Languages. Concurrency. Multiprocessors. Processes vs. Threads. Computation Abstractions
CMSC 330: Organization of Programming Languages Multithreaded Programming Patterns in Java CMSC 330 2 Multiprocessors Description Multiple processing units (multiprocessor) From single microprocessor to
More informationExercise Session Week 8
Chair of Software Engineering Java and C# in Depth Carlo A. Furia, Marco Piccioni, Bertrand Meyer Exercise Session Week 8 Quiz 1: What is printed? (Java) class MyTask implements Runnable { public void
More informationConcurrency. CSCI 136: Fundamentals of Computer Science II Keith Vertanen
Concurrency http://csunplugged.org/routing-and-deadlock CSCI 136: Fundamentals of Computer Science II Keith Vertanen Overview Multi-threaded programs Multiple simultaneous paths of execution Seemingly
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 informationMVP1: Introduction to concurrency in JAVA
MVP1: Introduction to concurrency in JAVA Concurrency? A naive definition: More than one thing (activity) at a time. Independent activities: web download, number crunching, program editing, print. Dependent
More informationMultiple Choice Questions: Identify the choice that best completes the statement or answers the question. (15 marks)
M257 MTA Spring2010 Multiple Choice Questions: Identify the choice that best completes the statement or answers the question. (15 marks) 1. If we need various objects that are similar in structure, but
More informationConcurrency. Fundamentals of Computer Science
Concurrency http://csunplugged.org/routing-and-deadlock Fundamentals of Computer Science Outline Multi-threaded programs Multiple simultaneous paths of execution Seemingly at once (single core) Actually
More informationJAVA EXAMPLES - SOLVING DEADLOCK
JAVA EXAMPLES - SOLVING DEADLOCK http://www.tutorialspoint.com/javaexamples/thread_deadlock.htm Copyright tutorialspoint.com Problem Description: How to solve deadlock using thread? Solution: Following
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 informationUser Space Multithreading. Computer Science, University of Warwick
User Space Multithreading 1 Threads Thread short for thread of execution/control B efore create Global During create Global Data Data Executing Code Code Stack Stack Stack A fter create Global Data Executing
More informationObject-oriented programming. and data-structures CS/ENGRD 2110 SUMMER 2018
Object-oriented programming 1 and data-structures CS/ENGRD 2110 SUMMER 2018 Lecture 1: Types and Control Flow http://courses.cs.cornell.edu/cs2110/2018su Lecture 1 Outline 2 Languages Overview Imperative
More informationGenerics and collections
Generics From JDK 1.5.0 They are similar to C++ templates They allow to eliminate runtime exceptions related to improper casting (ClassCastException) Traditional approach public class Box { private Object
More informationLecture 4. The Java Collections Framework
Lecture 4. The Java s Framework - 1 - Outline Introduction to the Java s Framework Iterators Interfaces, Classes and Classes of the Java s Framework - 2 - Learning Outcomes From this lecture you should
More informationPrinciples of Software Construction: Concurrency, Part 1
Principles of Software Construction: Concurrency, Part 1 Josh Bloch Charlie Garrod School of Computer Science 1 Administrivia Midterm review tomorrow 7-9pm, HH B103 Midterm on Thursday HW 5 team signup
More information7. MULTITHREDED PROGRAMMING
7. MULTITHREDED PROGRAMMING What is thread? A thread is a single sequential flow of control within a program. Thread is a path of the execution in a program. Muti-Threading: Executing more than one thread
More informationReading from URL. Intent - open URL get an input stream on the connection, and read from the input stream.
Simple Networking Loading applets from the network. Applets are referenced in a HTML file. Java programs can use URLs to connect to and retrieve information over the network. Uniform Resource Locator (URL)
More informationSynchronization SPL/2010 SPL/20 1
Synchronization 1 Overview synchronization mechanisms in modern RTEs concurrency issues places where synchronization is needed structural ways (design patterns) for exclusive access 2 Overview synchronization
More informationcs Java: lecture #6
cs3101-003 Java: lecture #6 news: homework #5 due today little quiz today it s the last class! please return any textbooks you borrowed from me today s topics: interfaces recursion data structures threads
More informationSynchronization in Java
Synchronization in Java Nelson Padua-Perez Bill Pugh Department of Computer Science University of Maryland, College Park Synchronization Overview Unsufficient atomicity Data races Locks Deadlock Wait /
More informationDeadlock. Only one process can use the resource at a time but once it s done it can give it back for use by another process.
Deadlock A set of processes is deadlocked if each process in the set is waiting for an event that can be caused by another process in the set. The events that we are mainly concerned with are resource
More informationG Programming Languages Spring 2010 Lecture 13. Robert Grimm, New York University
G22.2110-001 Programming Languages Spring 2010 Lecture 13 Robert Grimm, New York University 1 Review Last week Exceptions 2 Outline Concurrency Discussion of Final Sources for today s lecture: PLP, 12
More informationCMSC 330: Organization of Programming Languages. Threads Classic Concurrency Problems
: Organization of Programming Languages Threads Classic Concurrency Problems The Dining Philosophers Problem Philosophers either eat or think They must have two forks to eat Can only use forks on either
More informationCS/B.TECH/CSE(New)/SEM-5/CS-504D/ OBJECT ORIENTED PROGRAMMING. Time Allotted : 3 Hours Full Marks : 70 GROUP A. (Multiple Choice Type Question)
CS/B.TECH/CSE(New)/SEM-5/CS-504D/2013-14 2013 OBJECT ORIENTED PROGRAMMING Time Allotted : 3 Hours Full Marks : 70 The figures in the margin indicate full marks. Candidates are required to give their answers
More informationConcurrency in Object Oriented Programs 1. Object-Oriented Software Development COMP4001 CSE UNSW Sydney Lecturer: John Potter
Concurrency in Object Oriented Programs 1 Object-Oriented Software Development COMP4001 CSE UNSW Sydney Lecturer: John Potter Outline Concurrency: the Future of Computing Java Concurrency Thread Safety
More informationPrinciples of Software Construction: Concurrency, Part 1
Principles of Software Construction: Concurrency, Part 1 Josh Bloch Charlie Garrod School of Computer Science 1 Administrivia Midterm review tomorrow 7-9pm Midterm on Thursday If you re still looking for
More informationCSCI 201L Final Written Spring % of course grade
Name SOLUTION Final Score ID Extra Credit Section (circle one): MW 8:30-9:50 TTh 9:30-10:50 TTh 11:00-12:20 12% of course grade 1. Servlets Explain the difference between a GET and POST form submission.
More informationCS360 Lecture 10 Multithreading
Tuesday, March 9, 2004 Reading Exception Handling: Chapter 15 Multithreading: Chapter 16 CS360 Lecture 10 Multithreading Declaring New Exception Types Most programmers use existing exception classes from
More information1) Discuss the mutual exclusion mechanism that you choose as implemented in the chosen language and the associated basic syntax
Lab report Project 3 Mihai Ene I have implemented the solution in Java. I have leveraged its threading mechanisms and concurrent API (i.e. concurrent package) in order to achieve the required functionality
More informationMultithreading Pearson Education, Inc. All rights reserved.
1 23 Multithreading 2 23.1 Introduction Multithreading Provides application with multiple threads of execution Allows programs to perform tasks concurrently Often requires programmer to synchronize threads
More informationSynchronization. Announcements. Concurrent Programs. Race Conditions. Race Conditions 11/9/17. Purpose of this lecture. A8 released today, Due: 11/21
Announcements Synchronization A8 released today, Due: 11/21 Late deadline is after Thanksgiving You can use your A6/A7 solutions or ours A7 correctness scores have been posted Next week's recitation will
More informationMultitasking Multitasking allows several activities to occur concurrently on the computer. A distinction is usually made between: Process-based multit
Threads Multitasking Multitasking allows several activities to occur concurrently on the computer. A distinction is usually made between: Process-based multitasking Thread-based multitasking Multitasking
More informationAdvanced Concepts of Programming
Berne University of Applied Sciences E. Benoist / E. Dubuis January 2005 1 Multithreading in Java Java provides the programmer with built-in threading capabilities The programmer can create and manipulate
More informationConcurrency Quiz: Java Threads
Concurrency Quiz: Java Threads First name, last name:................................................................. Background information In this part of the quiz, we would like to collect some information
More informationMulti-threading in Java. Jeff HUANG
Multi-threading in Java Jeff HUANG Software Engineering Group @HKUST Do you use them? 2 Do u know their internals? 3 Let s see File DB How can they service so many clients simultaneously? l 4 Multi-threading
More informationThe Java Collections Framework. Chapters 7.5
The Java s Framework Chapters 7.5 Outline Introduction to the Java s Framework Iterators Interfaces, Classes and Classes of the Java s Framework Outline Introduction to the Java s Framework Iterators Interfaces,
More informationParallel & Concurrent Programming
Program Parallel & Concurrent Programming CSCI 334 Stephen Freund Memory Count Words A.html Count cow: cow:28 moo: moo:3 the: the:35 wombat: wombat:16 purple: purple:3
More informationThreads and Java Memory Model
Threads and Java Memory Model Oleg Šelajev @shelajev oleg@zeroturnaround.com October 6, 2014 Agenda Threads Basic synchronization Java Memory Model Concurrency Concurrency - several computations are executing
More informationParallel Programming Languages COMP360
Parallel Programming Languages COMP360 The way the processor industry is going, is to add more and more cores, but nobody knows how to program those things. I mean, two, yeah; four, not really; eight,
More informationModule Contact: Dr Anthony J. Bagnall, CMP Copyright of the University of East Anglia Version 2
UNIVERSITY OF EAST ANGLIA School of Computing Sciences Main Series UG Examination 2014/15 PROGRAMMING 2 CMP-5015Y Time allowed: 2 hours Answer four questions. All questions carry equal weight. Notes are
More informationThem Threads, Them Threads, Them Useless Threads
Them Threads, Them Threads, Them Useless Threads Dr Russel Winder Partner, Concertant LLP russel.winder@concertant.com Copyright 2008 Russel Winder 1 Aims and Objectives of the Session Raise awareness
More informationG51PGP Programming Paradigms. Lecture 009 Concurrency, exceptions
G51PGP Programming Paradigms Lecture 009 Concurrency, exceptions 1 Reminder subtype polymorphism public class TestAnimals public static void main(string[] args) Animal[] animals = new Animal[6]; animals[0]
More informationWriting Parallel Programs COMP360
Writing Parallel Programs COMP360 We stand at the threshold of a many core world. The hardware community is ready to cross this threshold. The parallel software community is not. Tim Mattson principal
More informationInfo 408 Distributed Applications Programming Exercise sheet nb. 4
Lebanese University Info 408 Faculty of Science 2017-2018 Section I 1 Custom Connections Info 408 Distributed Applications Programming Exercise sheet nb. 4 When accessing a server represented by an RMI
More informationCSCI 136 Written Exam #1 Fundamentals of Computer Science II Spring 2015
CSCI 136 Written Exam #1 Fundamentals of Computer Science II Spring 2015 Name: This exam consists of 5 problems on the following 7 pages. You may use your double- sided hand- written 8 ½ x 11 note sheet
More informationLe L c e t c ur u e e 7 To T p o i p c i s c t o o b e b e co c v o e v r e ed e Multithreading
Course Name: Advanced Java Lecture 7 Topics to be covered Multithreading Thread--An Introduction Thread A thread is defined as the path of execution of a program. It is a sequence of instructions that
More informationCOMP346 Winter Tutorial 4 Synchronization Semaphores
COMP346 Winter 2015 Tutorial 4 Synchronization Semaphores 1 Topics Synchronization in Details Semaphores Introducing Semaphore.java 2 Synchronization What is it? An act of communication between unrelated
More informationi219 Software Design Methodology 11. Software model checking Kazuhiro Ogata (JAIST) Outline of lecture
i219 Software Design Methodology 11. Software model checking Kazuhiro Ogata (JAIST) Outline of lecture 2 Concurrency Model checking Java Pathfinder (JPF) Detecting race condition Bounded buffer problem
More informationContents. 6-1 Copyright (c) N. Afshartous
Contents 1. Classes and Objects 2. Inheritance 3. Interfaces 4. Exceptions and Error Handling 5. Intro to Concurrency 6. Concurrency in Java 7. Graphics and Animation 8. Applets 6-1 Copyright (c) 1999-2004
More informationLecture 8: September 30
CMPSCI 377 Operating Systems Fall 2013 Lecture 8: September 30 Lecturer: Prashant Shenoy Scribe: Armand Halbert 8.1 Semaphores A semaphore is a more generalized form of a lock that can be used to regulate
More informationComputation Abstractions. CMSC 330: Organization of Programming Languages. So, What Is a Thread? Processes vs. Threads. A computer.
CMSC 330: Organization of Programming Languages Threads Computation Abstractions t1 t2 t1 t3 t2 t1 p1 p2 p3 p4 CPU 1 CPU 2 A computer t4 t5 Processes (e.g., JVM s) Threads CMSC 330 2 Processes vs. Threads
More informationPart IV Other Systems: I Java Threads
Part IV Other Systems: I Java Threads Spring 2019 C is quirky, flawed, and an enormous success. 1 Dennis M. Ritchie Java Threads: 1/6 Java has two ways to create threads: Create a new class derived from
More informationPrinciples of Software Construction: Concurrency, Part 2
Principles of Software Construction: Concurrency, Part 2 Josh Bloch Charlie Garrod School of Computer Science 1 Administrivia Homework 5a due now You will get early feedback tomorrow! Thank your TAs 2nd
More informationThe Dining Philosophers Problem CMSC 330: Organization of Programming Languages
The Dining Philosophers Problem CMSC 0: Organization of Programming Languages Threads Classic Concurrency Problems Philosophers either eat or think They must have two forks to eat Can only use forks on
More informationCMSC 330: Organization of Programming Languages
CMSC 330: Organization of Programming Languages Threads Synchronization Refers to mechanisms allowing a programmer to control the execution order of some operations across different threads in a concurrent
More informationSynchronization Lecture 23 Fall 2017
Synchronization Lecture 23 Fall 2017 Announcements A8 released today, Due: 11/21 Late deadline is after Thanksgiving You can use your A6/A7 solutions or ours A7 correctness scores have been posted Next
More informationCP122 CS I. Iteration
CP122 CS I Iteration Tech News! Pix2Pix: machine learning translation of images https://affinelayer.com/pixsrv/ Tech News! Pix2Pix: machine learning translation of images https://affinelayer.com/pixsrv/
More informationPerformance Throughput Utilization of system resources
Concurrency 1. Why concurrent programming?... 2 2. Evolution... 2 3. Definitions... 3 4. Concurrent languages... 5 5. Problems with concurrency... 6 6. Process Interactions... 7 7. Low-level Concurrency
More informationAdvanced Programming Methods. Lecture 6 - Concurrency in Java (1)
Advanced Programming Methods Lecture 6 - Concurrency in Java (1) Overview Introduction Java threads Java.util.concurrent References NOTE: The slides are based on the following free tutorials. You may want
More informationRobotics and Autonomous Systems
1 / 38 Robotics and Autonomous Systems Lecture 10: Threads and Multitasking Robots Simon Parsons Department of Computer Science University of Liverpool 2 / 38 Today Some more programming techniques that
More informationThreads and Locks. CSCI 5828: Foundations of Software Engineering Lecture 09 09/22/2015
Threads and Locks CSCI 5828: Foundations of Software Engineering Lecture 09 09/22/2015 1 Goals Cover the material presented in Chapter 2, Day 1 of our concurrency textbook Creating threads Locks Memory
More informationMulti-Threaded Programming Design CSCI 201 Principles of Software Development
Multi-Threaded Programming Design CSCI 201 Principles of Software Development Jeffrey Miller, Ph.D. jeffrey.miller@usc.edu Blocking Queues Outline Multi-Threaded Programming Design USC CSCI 201L Thread
More informationCSCI 136 Written Exam #1 Fundamentals of Computer Science II Spring 2012
CSCI 136 Written Exam #1 Fundamentals of Computer Science II Spring 2012 Name: This exam consists of 5 problems on the following 8 pages. You may use your double- sided hand- written 8 ½ x 11 note sheet
More informationMODULE 6q - Exceptions
MODULE 6q - Exceptions THE TRY-CATCH CONSTRUCT Three different exceptions are referred to in the program below. They are the ArrayIndexOutOfBoundsException which is built-into Java and two others, BadLuckException
More informationMultithreaded Programming
Multithreaded Programming Multithreaded programming basics Concurrency is the ability to run multiple parts of the program in parallel. In Concurrent programming, there are two units of execution: Processes
More informationToday: Synchronization. Recap: Synchronization
Today: Synchronization Synchronization Mutual exclusion Critical sections Example: Too Much Milk Locks Synchronization primitives are required to ensure that only one thread executes in a critical section
More informationECE 462 Object-Oriented Programming using C++ and Java. Scheduling and Critical Section
ECE 462 Object-Oriented Programming g using C++ and Java Scheduling and Critical Section Yung-Hsiang Lu yunglu@purdue.edu d YHL Scheduling and Critical Section 1 Thread States born terminated ready running
More informationCOURSE 11 PROGRAMMING III OOP. JAVA LANGUAGE
COURSE 11 PROGRAMMING III OOP. JAVA LANGUAGE PREVIOUS COURSE CONTENT Input/Output Streams Text Files Byte Files RandomAcessFile Exceptions Serialization NIO COURSE CONTENT Threads Threads lifecycle Thread
More informationCMSC 330: Organization of Programming Languages. The Dining Philosophers Problem
CMSC 330: Organization of Programming Languages Threads Classic Concurrency Problems The Dining Philosophers Problem Philosophers either eat or think They must have two forks to eat Can only use forks
More informationQuestion Points Score Total 100
Midterm Exam #1 CMSC 433 Programming Language Technologies and Paradigms Spring 2014 March 13, 2014 Guidelines Put your name on each page before starting the exam. Write your answers directly on the exam
More information