2013 by Barry Wittman, Aditya Mathur, Tim Korb.
Distributed by Purdue University Press, http://www.thepress.purdue.edu.
Wittman | To the set of all people that I do not dedicate this book to |
Mathur | To my mother |
Korb | To my family |
Contents
Preface to Draft 6.0
Welcome to Start Concurrent! This book is intended as an entry point into the multicore revolution that is now in full swing. It is designed to introduce students to concurrent programming at the same time they are learning the basics of sequential programming, early in their college days. After mastering the concepts covered here, students should be prepared when they encounter more complex forms of concurrency in advanced courses and in the workplace. A generation of students who learn concurrency from their first course will be ready to exploit the full power of multicore chips by the time they join the workforce.
Multicore processors are omnipresent. Whether you use a desktop or a laptop, chances are that your computer has a multicore chip at its heart. Desktop parallel computers have been prophesied for years. That time has come. Parallel computers sit on our desks and our laps. This progress in microprocessor technology has thrown a challenge to educators: How can we teach concurrent programming?
Computer programming has been taught in academia for decades. However, the unwritten goal in nearly every beginning programming class has been teaching students to write, compile, test, and debug sequential programs. Material related to concurrent programming is often left to courses about operating systems and programming languages or courses in high performance computing. Now that parallel computers are on our desks, should we consider introducing the fundamentals of concurrent programming in beginner classes in programming? Of course, there are many opinions about this question.
For our part, we believe that concurrent programming can be, and should be, taught to first year students. This book aims at introducing concurrent programming from almost the first day. The rationale for our belief stems from another belief that procedural thinking, sequential as well as concurrent, is natural. People knew how to solve problems in a sequential manner, long before the study of algorithms became a formal subject and computer science a formal discipline. And this rationale applies to problem solving using a collection of sequential solutions applied concurrently. Watch a cook in the kitchen and you will see concurrency in action. Watch a movie and you will see concurrency in action as various subplots, scenes, and flashbacks weave the plot together. Parents use concurrent solutions to solve day-to-day problems as they juggle caring for their children, a career, and a social life.
If people naturally solve problems sequentially and concurrently, why do we need to teach them programming? Programming is a way to map an algorithmic solution of a problem to an artificial language such as Java. It is an activity that requires formal analysis, specialized vocabulary, and razor sharp logic. The real intellectual substance of programming lies in this mapping process. What is the best way to transform a sequential solution to an artificial language? How can a sequential solution be broken into concurrent parts that run faster than the original? How can a large problem be divided into small, manageable chunks that can be programmed separately and then integrated into a whole? In addition, there are issues of testing, debugging, documentation, and management of the software development process, which combine to make programming a limitless field for intellectual curiosity.
Target audience
This book is intended to teach college level students with no programming experience over a period of two semesters. Although we start with concurrency concepts from the very beginning, it is difficult for students with no prior programming experience to write useful multithreaded programs by the end of their first semester. By the end of the second semester, however, this book can lead a student from a blank slate to a capable programmer of complex parallel programs that exploit the power of multicore processors.
The content in this book could also be used for single semester courses. onward could then be covered in a single semester.
Nature of the material covered
Java is a complex language. Its long list of features makes it difficult for an instructor to decide what to cover and what to leave out. Often there is a tendency to cover more material than less. We have noticed that todays student uses not only a textbook but also the large volume of material available on the web to learn any subject, including programming. Our focus is consequently more on fundamental elements of programming and less on giving a complete description of Java. Where appropriate we direct the student to websites where relevant reference material can be found.
Classes and objects are an essential part of Java. Some educators have adopted an objects early approach that focuses heavily on object oriented principles from the very beginning. Although we see many merits in this approach, we feel compelled to start with logic, arithmetic, and control flow so that students have a firm foundation of what to put inside their objects. A full treatment of classes and objects unfolds throughout the book, moving naturally from monolithic programs to decomposition into methods to full object orientation.
Organization
The material covered can be divided up in different ways depending on the needs of the instructor or the student. debugging and testing, which is even more crucial in a concurrent environment. The rest of the book covers advanced material relating to OO design, data structures, and I/O.
Chapter layout
One feature of this book that separates it from many Java textbooks is its problem-driven approach. Most chapters are divided into the following parts.
Problem
A motivating problem is given at the beginning of almost all chapters. This problem is intended to show the value of the material covered in the chapter as well as sketching a practical application.
Concepts
One or more short sections devoted to concepts is given in each chapter. The concepts described in these sections are the fundamental topics covered in the chapter, as well as main ideas needed to solve the chapters motivating problem. These concepts are intended to be broad and language neutral. Java syntax is kept to an absolute minimum in these sections.
Syntax
Each chapter has one or more sections describing the Java syntax needed to implement the concepts already described in the Concepts sections. These sections are typically longer and have numbered examples in Java code sprinkled throughout.
Solution
After the appropriate concepts and Java syntax needed to solve the motivating problem have been given, a solution to the motivating problem is provided near the end of the chapter. In this way, students are given plenty of time to think about the approach needed to solve the problem before the answer is given.
Concurrency
For all of the chapters except for , the dedicated concurrency chapters, additional relevant concurrency concepts and syntax are introduced in these specially marked sections, spreading concurrency throughout the book.