Download Ален Холаб. Приручаем потоки Java by Allen Holub PDF

By Allen Holub

Studying tips to write multithreaded functions is the most important to taking complete benefit of the Java platform. In Taming Java Threads, famous columnist and Java professional Allen Holub presents Java programmers with the knowledge they should write genuine multithreaded courses - courses with actual code. Holub offers an in-depth clarification of the way threads paintings in addition to information regarding find out how to resolve universal difficulties similar to deadlocks and race stipulations. He not just explains universal difficulties, but in addition presents the unusual options that mark the variation among production-level code and toy demos.Topics lined during this booklet comprise the structure of threads; the mutex and lock administration; variables and counting semaphores; timers, alarms, and swing thread security; observers and multicasters; singletons, severe periods, and reader/writer locks; threads in an object-oriented global; and object-oriented threading architectures.While it really is necessary to construct help for threading right into a Java software from the very starting, so much books at the topics of Java-UI development and Java networking slightly contact on threading subject matters. besides being a simple Java reference, this e-book is a must-read for any Java developer.

Show description

Read Online or Download Ален Холаб. Приручаем потоки Java PDF

Similar programming: programming languages books

Beginning Java Objects: From Concepts To Code, 2nd Edition

Between Java's many beautiful gains as a programming language, its object-oriented nature is vital to making strong, reusable code and functions which are effortless to take care of and expand. to exploit those features, you are going to needn't in basic terms to grasp the syntax of the Java language, but in addition to realize a realistic figuring out of what items are all approximately, and extra importantly, tips on how to constitution a Java program from the floor as much as utilize items.

Additional info for Ален Холаб. Приручаем потоки Java

Example text

The dequeueing thread acquires the monitor, wait() returns, an object is dequeued, and dequeue() returns, releasing the monitor. 1, line 22) is pretty important. First, consider what would happen if you replaced the notify() call with a call to notifyAll(). Imagine that several threads were simultaneously trying to dequeue something from the same empty queue. All of these threads are blocked on a single condition variable, waiting for an enqueue operation to be executed. When enqueue() sets the condition to true by calling notifyAll(), the threads are all released from the wait (moved from a suspended to a runnable state).

This flaw in Java compounds the problems of nested-monitor lockout because it becomes very difficult to break out of the nested monitor using a simple timeout strategy. 5. The code on lines 12 to 25 creates a thread that fires up a server-side socket and then sits on it: A client connection is established, but no data is ever sent to the client. Down on line 35, a client-side socket is created and connected to the server-side socket. A second 50 thread is then created to read from that client-side socket (on line 42).

48 Inner Classes I use inner classes heavily throughout the book. A program is simply easier to read and maintain if you define all symbols in the most restrictive scope possible. The same thinking that precludes you from moving your local variables out to class scope, should be applied to classes as well. They have no business being at package scope unless they're used by more than one class. That is, if some "helper" class is used only by one other class, the helper class should be defined as an inner class of the class that uses it.

Download PDF sample

Rated 4.39 of 5 – based on 46 votes