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.
Have complex solutions. Partly, it is due to the fact that more advanced features in Java are generally designed to tackle more complicated problems. The tools we introduce in this chapter do not allow you to solve a problem you could not solve before. Instead, the tools in this chapter and in the next one make solving a problem easier and less susceptible to errors. A relatively long, complicated list of Java statements was necessary to solve problems like the statistics program or Conway’s.
1.8 We use hexadecimal because it is straightforward to convert from it to binary or back. The following table lists binary equivalents for the 16 hexadecimal digits. With the help of the table above, let’s convert 3FA16 to binary. By simple substitution, 3FA16 = 0011 1111 10102. Note that we have grouped the binary digits into clusters of 4 bits each. Of course, the leftmost zeroes in the binary equivalent are useless as they do not contribute to the value of the number. Exercise 1.9.
Represented as (0,0,0), i.e. zero values for each of the three bytes. At the same time, the lightest color, white, is represented conceptually as (255,255,255). In principle, we can perform a very simple filter to increase contrast and lightness by simply doubling all the pixel values. Given red, green, and blue color values stored in three byte variables called red, green, and blue, a naive implementation of this filter might be as follows. red *= 2; green *= 2; blue *= 2; In Java, this code.
Statement coverage, 427 subdomain, 426 tools for concurrency, 431 white box, 427 text box, 203 editor, 173 file, 526, 533, 538 text editor, 172 this, 244, 245, 257, 281, 345 Thread, 290, 319, 342, 422, 440 join(), 102, 321, 324, 329, 336, 339, 518, 546 NORM_PRIORITY, 332 resume(), 422 sleep(), 167, 299, 330–332, 339, 347 start(), 321, 323, 517, 546 stop, 422 suspend(), 422, 428 wait(), 330 yield(), 330, 331, 333 Thread deprecated methods, 422 thread, 60, 317 background.
6.02214179 E23 The first of the above two statements declares roomArea to be of type float. Note that the declaration does not initialize roomArea to any value. Similar to integer primitive types, an uninitialized floating point variable contains 0.0, but Java usually forces the programmer to assign a value to a variable before using it. The second of the above two statements declares avogadro to be a variable of type double and initializes it to the well-known Avogadro constant 6.02214179 ×.