Utilizing a Multi-Core System with the Actor Model
Demand for multi-core/multi-processor applications is growing,
but developing for a multi-threaded application does not require a steep learning curve or an understanding of
complicated edge cases. Learn how to develop efficient multi-threaded applications without using
synchronized blocks.
by James Leigh
November 11, 2008
typical multi-threaded application in Java contains numerous synchronized methods and statements. They might also
contain calls to the methods wait() and notify() that were introduced with Java 1.0, but these methods provide very primitive functionality and are easily misused. Java 5 introduced the java.util.concurrent package, which provides some higher-level abstractions away from wait() and notify(). However, it can still be a challenge to appropriately use the synchronized and volatile keywords. Even when used correctly, getting them used efficiently can require complicated orchestrations of locks.
The biggest criticism of Java's synchronization is performance. Synchronization blocks become overly encompassing too easily. Although a synchronization block on its own is far from slow, when overly encompassing, it becomes a contested synchronization block. Contested synchronized blocks, or other blocking operations, are slow and require the OS to put threads to sleep and use interrupts to activate them. This puts pressure on the scheduler, resulting in significant performance degradation.
It's quick, easy and you get access to all the articles on DevX.
This registration/login is to allow you to read articles on devx.com. Already a member?
To become a member of DevX.com create your Member Profile by completing the form below. Membership is free!