Start Concurrent: An Introduction to Problem Solving in Java with a Focus on Concurrency

Start Concurrent: An Introduction to Problem Solving in Java with a Focus on Concurrency

Barry Wittman, Tim Korb

Language: English

Pages: 656


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.

Essential Software Architecture (2nd Edition)

Architectures for Computer Vision: From Algorithm to Chip with Verilog

Quantum Information, Computation and Communication

Quantum Information, Computation and Communication

Computer Science Illuminated





















uses this method will have to have a try-catch block or specify that it also throws InterruptedException. A method can throw many different exceptions, and you can simply list them out after the throws keyword, separated by commas. Almost every exception thrown in Java is a child class of Exception, RuntimeException, or Error. Any descendant of RuntimeException or Error is an unchecked exception and is exempt from the catch or specify requirement. Any direct descendant of Exception is a checked

the threads array will need to be a static field. Figure 13.8 illustrates this process. Once you have implemented this design, test it against the original SumThread class to see how it performs. Restrict the number of threads you create to a power of 2 to make it easier to determine which threads wait and which threads terminate. Chapter 14 Synchronization Sharing is sometimes more demanding than giving. –Mary Catherine Bateson 14.1 Introduction Concurrent programs allow

chopsticks separately above, we have already gotten ourselves into trouble. 22 private void getChopstick ( int location ) 23 throws InterruptedException { 24 if( location < 0 ) 25 location += SEATS ; 26 synchronized ( chopsticks ) { 27 while ( chopsticks [ location ] ) 28 chopsticks.wait (); 29 chopsticks [ location ] = true ; 30 } 31 System.out.println (" Philosopher " + seat + 32 " picked up chopstick " + location + "."); 33 } 34 35 private void eat () { 36 // done eating , put

public void actionPerformed ( ActionEvent e){ 55 System.out.println (" Exit "); 56 soundGame.dispose (); 57 } 58 }); 59 soundGame.setSize (175 ,175) ; // Set size in pixels 60 soundGame.setDefaultCloseOperation ( 61 JFrame.DISPOSE_ON_CLOSE ); 62 soundGame.setVisible ( true ); // Display it 63 } 64 } The actions for the bark button are very similar to the actions for the chirp button, but the actions for stop are different. When stop is clicked, the action listener does not know which

needs to be pre-allocated. Instead, we capture all the lines of input into a linked list called list. Program 18.6: A program that uses the LinkedList class to store input read from a file. ( 1 import java.util.Arrays ; 2 import java.util.Scanner ; 3 4 public class UseLinkedList { 5 public static void main ( String [] args ) { 6 Scanner in = new Scanner (; 7 LinkedList list = new LinkedList (); 8 9 while (in. hasNextLine ()) 10 list.add(in. nextLine ());

Download sample