Let's write a ThreadPool together. First exercise. A sea of scared faces. Is the teacher kidding?
"Mastering Threads" is an intense one day course that starts with the basics of threads. We then look at laws that help us to write correct threaded code. We then go to higher-level constructs that make threading much easier to use. We ends with diagnosing race conditions and deadlocks.
Each section ends with exercises that you can solve to hone your skills as a Java programmers. Some of these exercises (write a ThreadPool) has challenged hundreds of Java programmers. In solving these, we learn how inter-thread communication works. We learn how to keep our classes thread-safe. We also learn about thread states.
We have a detailed walkthrough for each exercise. Furthermore, students can submit their solved exercises to firstname.lastname@example.org for marking. This helps in the learning aspect as they get feedback from the instructor.
We use OpenJDK 11 for this course, taking full advantage of the new var syntax. However, programmers with Java 6 or 7 knowledge will also be able to follow.
We are selective on what we cover in this. Our intention was to create a short course that will teach you enough to help you in your every day work. Job interview questions on concurrency should not be hard after this. "Mastering Threads" is an introductory course on the topic of concurrency. For a more thorough exposition, please consider "Extreme Java - Concurrency Performance".
Diese Schulung gibt es auch auf Deutsch.
Heinz Kabutz is the author of The Java Specialists’ Newsletter, a publication enjoyed by tens of thousands of Java experts in over 145 countries. His book “Dynamic Proxies (in German)” was #1 Bestseller on Amazon.de in Fachbücher für Informatik for about five minutes until Amazon fixed their algorithm. Thanks to a supportive mother, he has now sold 5 copies.
Heinz’s Java Specialists’ newsletter is filled with amusing anecdotes of life on the Island of Crete. He is a popular speaker at all the best Java conferences around the world, and also at some of the worst. He teaches Java courses in classrooms around the world, where his prime objective is to make absolutely sure that none of his students fall asleep. He is not always successful.