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

By Allen Holub

Studying tips to write multithreaded functions is the major to taking complete benefit of the Java platform. In Taming Java Threads, famous columnist and Java specialist Allen Holub presents Java programmers with the knowledge they should write genuine multithreaded courses - courses with actual code. Holub offers an in-depth rationalization of ways threads paintings besides information regarding find out how to clear up universal difficulties equivalent to deadlocks and race stipulations. He not just explains universal difficulties, but additionally offers the unusual ideas that mark the variation among production-level code and toy demos.Topics lined during this ebook contain the structure of threads; the mutex and lock administration; situation variables and counting semaphores; timers, alarms, and swing thread safeguard; observers and multicasters; singletons, serious periods, and reader/writer locks; threads in an object-oriented international; and object-oriented threading architectures.While it's necessary to construct aid for threading right into a Java application from the very starting, such a lot books at the topics of Java-UI development and Java networking slightly contact on threading themes. in addition to being a uncomplicated Java reference, this ebook is a must-read for any Java developer.

Show description

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

Similar programming: programming languages books

Java and the Java Virtual Machine: Definition, Verification, Validation

This ebook presents a high-level description, including a mathematical and an experimental research, of Java and of the Java digital laptop (JVM), together with a typical compiler of Java courses to JVM code and the safety serious bytecode verifier section of the JVM. the outline is based into language layers and laptop elements.

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

Example text

Test Classes Most of my classes contain a static inner class called Test, which contains a main() that runs a unit test on the class. jar file that you ship. 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.

Release(); 7. wait_for_true(); 8. acquire(); //<-- we are now blocked in this call 9. The dequeueing thread is preempted, just after calling notify(). The enqueue() method hasn't returned, so the enqueueing thread is still holding the lock. 10. A third thread now comes on the scene and calls dequeue(). There are now two threads both trying to acquire the same monitor at the same time: the dequeueing thread and the third thread I just introduced into the mix. 11. Because both dequeueing threads are blocked, the enqueueing thread is allowed to run.

Use it to wait for some condition to be true when a notify is received. notify(); The timeout will be reliable if you use the Spin_lock; it may not be reliable if you use wait(). @author Allen I. Holub */ 06: public final class Spin_lock 07: { /** A Gang-of-Four Strategy object that tells the spin lock the condition for which we're waiting. Override satisfied() to return true when the condition for which we're waiting becomes true. */ 08: public interface Condition 09: { boolean satisfied(); 10: } 11: /** Block until the condition specified by condition becomes true and the current Spin_lock is passed a release() message after the condition becomes true.

Download PDF sample

Ален Холаб. Приручаем потоки Java by Allen Holub
Rated 5.00 of 5 – based on 22 votes