Skip to main content

JSR-166y Provides New Concurrency Benefits

Posted by editor on August 27, 2008 at 6:18 AM PDT

Development of new and improved methods for programming multithreaded applications has never been as critical as it is today, due to the emergence of multicore processors. I've been developing multithreaded applications since the early 1990s, when I was implementing mathematical models on multi-processor Sun machines using Sun's threading libraries and its facilities for shared memory. Since much of the code I needed to multithread was written in Fortran 77, accomplishing the task of effectively spreading out the work over all the available processors required a substantial amount of effort (note: the Fortran was multithreaded by wrapping the code in C, and the C was multithreaded using Sun's libraries).

Anyone who has worked with native threads understands that multithreaded development puts you into an entirely different realm of difficulty, in terms of the programming itself (you need to develop thread-safe functions) and especially when it comes to debugging the application. What works wonderfully on a slower machine may not work at all on a faster multicore/multiprocessor machine.

If multithreaded applications are the future (I myself think they are, given that most home and office desktops will likely feature a many-core PC within the next few years), how will it be possible for developers to overcome the difficulties of multithreaded development? The answer (which has come as a welcome surprise to me) is that new programming frameworks are going to shield developers from those messy, difficult details of threading applications. For C++ developers, there is the ThreadingBuildingBlocks open source framework. Microsoft is working on ParallelFX.

Meanwhile, in the Java world, there is a lot of excitement about the innovations represented by JSR 166y. On the JavaLobby site, vaclav has just posted "Parallelize your arrays with JSR 166y", in which he illustrates methods for performing concurrent operations on arrays without the need to enmesh yourself in the details of the underlying threading activity. Vaclav says:

"The JSR-166y ... is really amazing in how nicely it shields developers from dealing with threads. I've spent some time experimenting with another very handy capability of JSR-166y, which are Parallel Arrays.

In brief, they allow you to perform operations like filtering or calculations on elements stored in a collection in parallel. And what is important, very little knowledge of concurrent programming is required to use Parallel Arrays. All you need to do is to define a bunch of predicates and mapping operations and chain them so that they get called on your collection.

I suppose I'm happy to have been a "pioneer" who got to actually "manage" all the details of creating, monitoring, and assessing the results of individual thread executions, on those early, powerful Sun multiprocessor machines. At the same time, I'm glad that the current generation of developers is going to be able to spend much more of their time and effort on developing new application functionality, rather than being required to devote 90% of their time to programming and debugging native thread issues. Today's new thread-abstraction frameworks, including the JSR-166y enhancements, provide a much more productive means for developing applications that will fully utilize today's multicore and future many-core systems.

In other Java Today news, Frank Sommers talks about ZeroTurnaround's JavaRebel tool and presents commentary from an interview with ZeroTurnaround Chief Architect Jevgeni Kabanov: "Developers using dynamic languages, such as Ruby, are used to a quick code-test-debug cycle: making changes to a piece of code and pressing the browser's reload button is often all that's needed to see the latest effects of a code edit. Java developers, by contrast, have to either restart an entire Java VM, or cause an application server to reload a Web application, for code changes to be visible during development. ZeroTurnaround's JavaRebel tool aims to bring the convenience of instant reload to the Java universe as well."

Meanwhile, alexismp spreads the news about the new build release for Shoal 1.1: "Shreedhar is announcing a new build release for Shoal 1.1, the GlassFish dynamic clustering framework. Version 1.1 is work in progress and offers a JoinedAndReadyNotificationSignal, multiple clusters support for the same member (useful for Sailfin's Converged Load-Balancer), cross subnet clustering support, etc."

In our Feature Article, Michael Bar-Sinai offers a novel technique for Complex Table Cell Rendering Made Simple.
After all, plain old text-only JTable cells are boring, but once you
start to mix multiple types of cell renderers in a table, your
getTableCellRendererComponent() method can get completely out of
control. In this article, Michael offers a performant and clever
alternative that looks up the needed renderer with class-based and
rule-based maps.

The latest Java Mobility Podcast is
Java Mobility Podcast 54: Kicking Butt with MIDP and MSA, in which
Jonathan Knudsen talks about his new book, Kicking Butt with MIDP and MSA, and his tutorial on the Lightweight UI Toolkit (LWUIT).

In today's Weblogs, Joshua Marinacci continues his applet series with "A Better Applet Experience, Part 2: Poster Frames": "In part one of this series I showed you how to set up a loading image, including an animated spinner gif. In this part I'll show you how use a screenshot or poster frame to speed up page loading. Quicktime movies have the concept of a poster frame. It's a single frame..."

Terrence Barr talks about how he's enabling people to keep in touch while he's on travel in his post
"Fire Eagle updates from your Java phone": "With all the travel I'm doing lately I've been looking for a convenient way to keep people who are interested in getting in touch with me updated on my current whereabouts - I don't know about you but I prefer to get phone calls and IM messages during my waking hours rather than at 3 am local time ;-)"

John Ferguson Smart presents a talk he gave at the Wellington JUG about Replication in Subversion 1.5: "One common requirement when you set up a Subversion repository concerns how it will be backed up. Another involves what happens if the main repository server goes down for some reason. Yet another is about how to deal with teams distributed across large distances or connected with limited networks. Subversion has some interesting solutions to all of these concerns..."

In today's Forums, michael_heinrichs continues the ongoing discussion about Screen size, layouts on multiple devices: "Yes, you are right. I would expect that the UI has to be designed for each screen separately. Although I think the major issue is not how it looks, but the usability. The screen size is one issue. It's not so much about resizing and "looking good", but about the amount of information you can show at once."

narirag asks a question about configuring check-passthrough with sun webserver loadbalancer.xml: "I am using the Sun Webserver 6.1 sp6 with loadbalancer plugin to route the traffic to the Sun application server 8.1. Currently the webserver is directing all the requests (both static and dynamic) succesfully to the Application servers listed in the loadbalancer.xml file. I would like to configure the Webserver to serve all the static content like html,css,gifs,png etc and forward the request to appserver in case the requested resource is not available on webserver."

Alex has further questions about the LWUIT ListModel and RMS: "Thanks to Shai for his latest blog entry which clears up a lot of things on the implementation of Lists (my previous question was about this). Alongside whith the post on the TextField (autocomplete) and the proxy pattern
implementation used to filter out entries this gives great insights on the
possibilities of LWUIT Lists. I however I need a litle piece of advice here on how to use the lwuit ListModel with RMS alongside with the Proxy pattern for filtering and
sorting of records."

Current and upcoming Java

Registered users can submit event listings for the Events Page using our events submission form.
All submissions go through an editorial review before being posted to the

Archives and Subscriptions: This blog is delivered weekdays as
the Java
Today RSS feed
. Also, once this page is no longer featured as the
front page of it will be
archived along with other past issues in the Archive.