Start Concurrent: An Introduction to Problem Solving in Java with a Focus on Concurrency
Barry Wittman, Tim Korb
Format: PDF / Kindle (mobi) / ePub
Multicore microprocessors are now at the heart of nearly all desktop and laptop computers. While these chips offer exciting opportunities for the creation of newer and faster applications, they also challenge students and educators. How can the new generation of computer scientists growing up with multicore chips learn to program applications that exploit this latent processing power? This unique book is an attempt to introduce concurrent programming to first-year computer science students, much earlier than most competing products.
This book assumes no programming background but offers a broad coverage of Java. It includes 159 numbered and numerous inline examples as well as 301 exercises categorized as –conceptual,— –programming,— and –experiments.— The problem-oriented approach presents a problem, explains supporting concepts, outlines necessary syntax, and finally provides its solution. All programs in the book are available for download and experimentation. A substantial index of 5,039 entries makes it easy for readers to locate relevant information.
In a fast-changing field, this book is continually updated and refined. The 2013 version is the sixth –draft edition— of this volume, and features numerous revisions based on student feedback.
stepping into them, on a case by case basis. As the program executes, the programmer can inspect the values of the variables in the code. This method of debugging is excellent because it allows the programmer to watch the execution of the code at whatever pace he or she desires. Pinpointing problems becomes trivial if you know which variables you need to watch. Despite the power of this technique, it has critics. Some older programmers look down on these tools because they make beginning
feature of step-through debuggers designed to make them easier to use. A user can specify a particular line of code (with some restrictions) as being a place where the debugger should pause execution. Debuggers typically rely on at least one breakpoint in order to skip all the preliminary parts of the code and skip straight to the perceived trouble spot. Sometimes an error will predictably crop up after many thousands of iterations of a loop or unpredictably in the case of bugs dependent on race
class, 251 inorder traversal, 512 input command line, 202 domain, 61 keyboard, 203 parsing, 289 redirection, 172, 176 standard, 462 instance, 240 instance data, 240 instance method, 239, 240 instanceof, 263, 446 instantiate, 68 instrument code, 431 int, 223, 230 int, 67, 71, 118 Integer, 96, 97, 259 MAX_VALUE, 99, 412 MIN_VALUE, 99 parseInt(), 97, 310 integer even, 207 odd, 207 Integer.MIN_VALUE, 174 integers negative, 17 integrated development environment (IDE), 42
would avoid this approach because it uses the confusing syntax in which the body of the for loop is a single empty statement followed by a semicolon. Likewise, the logic about exiting the loop and the condition of the if statement is murkier. 5.5 Concurrency: Loops Many programmers use concurrency for speedup. They want their programs to run faster. Most programs that run for a long time use loops to do repetitive tasks. If these loops are doing the same operation to many different pieces
than one thread of execution at a time without the need to run multiple programs by hand. Exercise 5.15 Exercises Conceptual Problems 5.1 If you have a String containing a long text and you want to count the number of words in the text that begin with the letter ’m’, which of the three kinds of loops would you use, and why? 5.2 In Example 5.2, our last version of the primality tester PrimalityTester2 computes the square root of the number being tested. Instead of computing this value