Skip to main content

editor's Blog

New National Java Competition In Planning Stage for Indonesian Students

Posted by editor on May 21, 2012 at 7:00 PM PDT

Frans Thamura, Java Champion and leader of JUG Indonesia, has announced on the Java.net Java User Groups JUG-Leaders email list that he is working on a national Java competition for students in Indonesia (the fourth most populous nation in the world). As the London Java Community's Martijn Verburg stated in reply, this is a fantastic idea!

In recent issues of Java Magazine I've been covering the Java Olympics that are taking place in Russia and nearby countries. That competition is for university students, with the winner gaining free attendance at the Moscow JavaOne next year.

If you've seen my articles about the Java Olympics in Java Magazine, you know how intense and exciting programming competitions can be. To have a new national competition in the fourth most populous nation in the world will be excellent! Who needs "American Idol" (a popular United States singing competition) or the Kentucky Derby, Preakness, and Belmont Stakes (the most major United States horse racing sequence) when you can actually watch software engineers compete in real time!?

I told Oracle's Alexander Belokrylov, who organized the Java Olympics, that I hope to be able to attend the second Java Olympics. Now I think I'm going to have to try to attend Indonesia's first competition as well! Hey, I may strive to become a globe-trotting Java competition reporter (if someone will pay me to do that, that is). These competitions are exciting, believe me (if you've never followed one).

Anyway, I wish Frans the best of luck in organizing Indonesia's new national Java competition!


Java.net Weblogs

Since my last blog post, several people have posted new java.net blogs:


Poll

Our current Java.net poll asks Was the decision to release Java 7 earlier by pushing some enhancements into Java 8 a good one?. Voting will be open until Friday, May 25.


Java News

Here are the stories we've recently featured in our Java news section:


Spotlights

Our latest Java.net Spotlight is the JCP Program Management Office's The JCP Program Targets Corporate Members of a Particular Kind:

The Java Community Process (JCP) Program Management Office (PMO) has relied on mature enterprises - such as Oracle, Nokia, IBM, Motorola, and Siemens - to form the backbone of the community. In recent years, to cultivate diversity the PMO has focused more on recruiting worldwide representatives from organizations and individuals in developer, academic, and user spheres. Now...


Subscriptions and Archives: You can subscribe to this blog using the java.net Editor's Blog Feed. You can also subscribe to the Java Today RSS feed and the java.net blogs feed. You can find historical archives of what has appeared the front page of Java.net in the java.net home page archive.

-- Kevin Farnham

Twitter: @kevin_farnham

Polls: Do You Read Java Magazine? And the Java 7/8 "Plan B" Decision (in Retrospect)

Posted by editor on May 15, 2012 at 4:40 PM PDT

Our most recently completed poll suggests that, while the new Java Magazine is starting to find a regular readership, there is still plenty of room for more growth.

A total of 266 votes were cast in the poll, along with a single comment. The exact question and results were:

Do you read Java Magazine?

  • 15% (39 votes) - I usually read most of the articles in each issue
  • 8% (21 votes) - I often read several articles per issue
  • 18% (47 votes) - I typically browse through the magazine, reading here and there
  • 5% (12 votes) - I subscribe, but haven't actually read anything yet
  • 5% (12 votes) - I don't subscribe to Java Magazine yet, but I plan to
  • 3% (9 votes) - I'm not interested in Java Magazine
  • 28% (74 votes) - What's Java Magazine?
  • 20% (52 votes) - Other

To be clear, this is not a scientific poll, merely a voluntary survey. Still, we can say that, among the people who chose to vote, about 40% are currently Java Magazine readers. Another 10% (those who subscribe but haven't read anything yet, and those who plan to subscribe) may become readers soon.

This leaves about half of the voters expressing that they are not Java Magazine readers. Only 3% saying they are not interested in Java Magazine, so almost half of the voters are not readers for another reason. 28% don't know what Java Magazine is. For these people, I recommend trying out Java Magazine, which is free!

It's interesting that the second most selected choice was "Other" (20%). One would assume that these voters are not current Java Magazine readers, but that they might be interested in reading Java Magazine (otherwise, wouldn't they have selected the "I'm not interested" option?). Java.net user grelf posted a comment that may provide a hint as to why so many people selected Other:

It is too hard to read. If I enlarge the text, navigation becomes a nightmare. It would be much better as a set of HTML pages.

I have seen complaints similar to this elsewhere...

Here's how your Java Magazine subscription currently works: when you get your email telling you a new issue of Java Magazine is available, it includes a link that you open in a web browser. But you don't have to view the issue in a browser. Once you're there, there is a button that lets you print the issue, and also a "Download" button that lets you save the issue as a PDF.

Printing the entire issue uses quite a lot of printer ink, since Java Magazine is a full-color production. I find downloading the PDF and viewing the magazine in my PDF viewer to be my most convenient method for enjoying the magazine.

Anyway, it would be interesting for the Java Magazine team, I'm sure, if they heard the format-related complaints people have. Please feel free to comment below about this, if you'd like, and I'll gladly relay the comments to Java Magazine [disclosure: I currently write news items for the Java Nation section of Java Magazine, and I'm planning to write full-scale technical articles in the future].

As for Java Magazine's actual content, I've not heard any complaints about that. It's high quality technology writing, in my opinion (again, note the above disclosure).

New poll: the decision to split Java 7 into Java 7 and Java 8

On 20 September 2010, Mark Reinhold announced: It's time for ... Plan B. This was the plan that would reduce what would be in Java 7, splitting out some of the previously planned features into a new Java 8. At the time, Mark noted: "The vo­lu­mi­nous feed­back was strongly--though not uni­ver­sally--in favor of Plan B."

Our current Java.net poll asks you what today, in retrospect, you think about this. The poll asks: Was the decision to release Java 7 earlier by pushing some enhancements into Java 8 a good one?. Voting will be open until Friday, May 25.


Java.net Weblogs

Since my last blog post, several people have posted new java.net blogs:


Java News

Here are the stories we've recently featured in our Java news section:


Spotlights

Our latest Java.net Spotlight is Deepak Vohrared's JSF 2.0 for the Cloud, Part Two:

JavaServer Faces 2.0 provides features ideally suited for the virtualized computing resources of the cloud. Here, in Part Two of a two-part article, we look at Ajax support, view parameters, preemptive navigation, event handling, and bookmarkable URLs...


Subscriptions and Archives: You can subscribe to this blog using the java.net Editor's Blog Feed. You can also subscribe to the Java Today RSS feed and the java.net blogs feed. You can find historical archives of what has appeared the front page of Java.net in the java.net home page archive.

-- Kevin Farnham

Twitter: @kevin_farnham

Comments

The link to Java Magazine fails: Page not found The ...

The link to Java Magazine fails:

Page not found
The requested page could not be found.

I think that may have been a temporary problem - all the ...

I think that may have been a temporary problem - all the links seem to work now.

Preparing to Compute Using the Fork/Join Framework, Part 1

Posted by editor on May 8, 2012 at 4:18 PM PDT

A couple weeks ago I figured out (more or less) what's wrong with Java threads. It's not that there's anything so wrong with Java threads per se -- it's just that they were designed to meet a need that is different from what developers face today: a world full of multicore processors powering everything from PCs to tablets to phones.

Now I'm working on converting a Java threads app that I developed a while back to utilize Java 7's new Fork/Join Framework. As the ForkBlur.java example illustrates, you can actually implement Fork/Join concurrency in a relatively small number of lines.

The fundamental component in the ForkBlur example is the ForkBlur class. Here's the key code that does the computation:

public class ForkBlur extends RecursiveAction {
  private int[] mSource;
  private int mStart;
  private int mLength;
  private int[] mDestination;
 
  private int mBlurWidth = 15; // Processing window size, should be odd.
 
  public ForkBlur(int[] src, int start, int length, int[] dst) {
    mSource = src;
    mStart = start;
    mLength = length;
    mDestination = dst;
  }

  // Average pixels from source, write results into destination.
  protected void computeDirectly() {
    int sidePixels = (mBlurWidth - 1) / 2;
    for (int index = mStart; index < mStart + mLength; index++) {
      // Calculate average.
      float rt = 0, gt = 0, bt = 0;
      for (int mi = -sidePixels; mi <= sidePixels; mi++) {
        int mindex = Math.min(Math.max(mi + index, 0), mSource.length - 1);
        int pixel = mSource[mindex];
        rt += (float)((pixel & 0x00ff0000) >> 16) / mBlurWidth;
        gt += (float)((pixel & 0x0000ff00) >>  8) / mBlurWidth;
        bt += (float)((pixel & 0x000000ff) >>  0) / mBlurWidth;
      }
     
      // Re-assemble destination pixel.
      int dpixel = (0xff000000     ) |
                   (((int)rt) << 16) |
                   (((int)gt) <<  8) |
                   (((int)bt) <<  0);
      mDestination[index] = dpixel;
    }
  }

  protected static int sThreshold = 10000;
 
  protected void compute() {
    if (mLength < sThreshold) {
      computeDirectly();
      return;
    }
   
    int split = mLength / 2;
   
    invokeAll(new ForkBlur(mSource, mStart,         split,           mDestination),
              new ForkBlur(mSource, mStart + split, mLength - split, mDestination));
  }

RecursiveAction is an abstract class that extends ForkJoinTask. Looking at the documentation for ForkJoinTask, you can see once again that standard Java threads are considered inadequate for the true parallel computational processing that modern multicore processors invite:

A ForkJoinTask is a thread-like entity that is much lighter weight than a normal thread. Huge numbers of tasks and subtasks may be hosted by a small number of actual threads in a ForkJoinPool...

In the code snippet, the computeDirectly() method is what performs the actual computations (in this case, a simplified method of blurring an image). You'll note that the input data is in the mSource array, the output is written to the mDestination array, and variables mStart and mLength define the locations within the array where the processing will occur. So, if mStart is set to 0 and mLength is set to the length of the array (i.e., the number of pixels in the image), you could call computeDirectly() and simply execute the blurring without parallel processing.

But, that's not what we want to do on our fancy N-core machine, right? We don't have time for that! Or, rather, our user doesn't... and we don't want them to switch to our competitor's app that takes full advantage of multicore processors, do we?

So, now let's look at the compute() method. This is indeed rather tiny:

  protected void compute() {
    if (mLength < sThreshold) {
      computeDirectly();
      return;
    }

    int split = mLength / 2;
   
    invokeAll(new ForkBlur(mSource, mStart,         split,           mDestination),
              new ForkBlur(mSource, mStart + split, mLength - split, mDestination));
  }

This says: if the current amount of the array to be processed is less than a threshold, call computeDirectly(); otherwise, divide the length to be processed in half, and utilize Java 5's invokeAll to execute the listed collection of tasks.

And what are the tasks we're going to execute if mLength was still larger than sThreshold? Two new ForkBlur() instantiations, one to process the first half of the array locations, the second to process the second half of the array locations. In other words, the work task is split into two tasks, each of half the size.

At this point you may be wondering: what about this sThreshold? How does that get selected? Do I just pull a value out of my hat? Call java.util.Random()?

This actually is one of my own primary questions regarding the Fork/Join Framework. If I have an N-core computer, I can divide a task into N equally-size pieces, launch N Java threads, and fully utilize my processor cores. So, if I'm utilizing the Fork/Join framework to do the same work, do I set a threshold value that accomplishes approximately the same thing? Or is that not the most efficient approach?

And, isn't it unreasonable to assume that a threshold value that optimizes performance on a particular device will also optimize performance on other devices that have different numbers of processing cores, different amounts of memory, etc. It doesn't seem like this threshold is going to be a "one-size-fits-all" proposition, to me...

This is definitely something I'll be researching as my experimentation continues.


Java.net Weblogs

Since my last blog post, several people have posted new java.net blogs:


Poll

Our current Java.net poll asks Do you read Java Magazine?. Voting will be open until Friday, May 11.


Java News

Here are the stories we've recently featured in our Java news section:


Spotlights

Our latest Java.net Spotlight is Neil Ghosh's JavaOne and Oracle Develope 2012 Hyderabad:

Like last year, JavaOne and Oracle Develop 2012 was organized and HICC on 3rd and 4th May 2012. The last time I attended such session was Tech Days when Oracle had just acquired Sun Miscrosystems. It was a two day program. This time the event was even larger...

Previously, we featured Tori Wieldt's JavaOne India Keynotes:

Over 2000 Indian developers were on hand to hear the opening keynotes at JavaOne in Hyderabad, India. The Nokia keynote provided an overview of the state of mobile technology and what it means for developers. The Java strategy keynote reminded the Indian Java community of the power and strength of Java and...


Subscriptions and Archives: You can subscribe to this blog using the java.net Editor's Blog Feed. You can also subscribe to the Java Today RSS feed and the java.net blogs feed. You can find historical archives of what has appeared the front page of Java.net in the java.net home page archive.

-- Kevin Farnham

Twitter: @kevin_farnham

Related Topics >>

Poll Result: Expected Impact of Lambda Expressions (Closures) on Programming with Java 8

Posted by editor on May 2, 2012 at 7:09 PM PDT

Brian Goetz recently provided new details on the status of JSR 335 in his OpenJDK document State of the Lambda: Libraries Edition. Project Lambda is a fundamentally important enhancement to Java 8. And, based on the response of developers in our recent poll asking how Lambda Expressions in Java 8 will affect their programming, the Java community is excited by the prospect of being able to implement closures in their applications.

A total of 437 votes were cast, along with a single comment. The exact question and results were:

To what extent do you expect Lambda Expressions (closures) in Java 8 to affect your programming?

  • 34% (148 votes) - They'll have a huge effect
  • 20% (88 votes) - They'll make some difference
  • 16% (68 votes) - No immediate effect (who knows when I'll finally be using Java 8?)
  • 9% (38 votes) - No effect, since closures aren't pertinent to the programming I do
  • 15% (64 votes) - I don't know
  • 7% (31 votes) - Other

These results (which, we recognize, are non-scientific) suggest that a great many Java developers consider the addition of Lambda Expressions to Java a very significant milestone.

Indeed, Java developers have been waiting for the inclusion of closures in Java for a very long time. Most of the long delay between Java 6 and Java 7 was filled with anticipation/hope that closures would be included in Java 7. However, as the years passed, and the uncertainty increased, the decision was ultimately made to split off some aspects of what was originally to be included in Java 7 into the next major release (i.e., Java 8), in order to facilitate getting key functionality out to the community sooner. I think most Java developers would agree this was a good decision (hmm.. this gives me an idea for a future poll!)...

But, getting back to this poll's results: a third of voters say Lambda Expressions will have a huge effect on their programming once Java 8 arrives; and more than half of the voters say closures will make at least some difference in their programming. We can assume that some of the 16% who selected "No immediate effect" will probably find Lambda Expressions useful once their platform reaches Java 8 (though that may be a long time from now).

rdohna wonders if there might be a bit too much enthusiasm for closures in Java, commenting:

They will be used even in cases where it only makes things more complicated than required.

Undoubtedly, that will happen in some cases. All the more reason to have experienced architects carefully communicating the design to the more junior developers...

In any case, it's been a long wait for closures / Lambda Expressions in Java. The wait isn't over yet, but it will be over soon; and developers are eagerly anticipating their arrival.

Current poll: Java Magazine

Our current Java.net poll asks Do you read Java Magazine?. Voting will be open until Friday, May 11.


Java.net Weblogs

Since my last blog post, Rex Young posted a new java.net blog:


Java News

Here are the stories we've recently featured in our Java news section:


Spotlights

Our latest Java.net Spotlight is Brian Goetz's State of the Lambda: Libraries Edition:

This is an informal overview of the major proposed library enhancements to take advantage of new language features, primarily lambda expressions and extension methods, specified by JSR 335 and implemented in the OpenJDK Lambda Project. This document describes the design approach taken in the rough prototype that has been implemented in the Lambda Project repository...


Subscriptions and Archives: You can subscribe to this blog using the java.net Editor's Blog Feed. You can also subscribe to the Java Today RSS feed and the java.net blogs feed. You can find historical archives of what has appeared the front page of Java.net in the java.net home page archive.

-- Kevin Farnham

Twitter: @kevin_farnham

Related Topics >>

Comments

You might have drawn some possibly erroneous conclusions ...

You might have drawn some possibly erroneous conclusions from this poll. Voting that one expects lambda expressions to have a significant effect on Java programming is not the same as voting that one supports the idea. I think that you should consider the wording of the poll before drawing conclusions about the results of the vote. I am certain that lambda expression will have a significan effect on Java programming. I am not nearly so convinced that the effect is a good thing.

I typically declare that Java.net polls are not scientific ...

I typically declare that Java.net polls are not scientific when I blog about them. There's a big difference between a survey where anyone who wants to vote can vote, and a scientifically constructed poll that asks specific individuals (who are considered to be a representative sample of an entire population) what their opinion is. So, my blogs about the polls are really just chit-chat about the topic at hand, since I have no genuine scientific data to go on.

So, in this particular poll, I was asking those who chose to vote to tell us the extent to which they expect Lambda Expressions in Java 8 to affect their own Java programming. Many state that they expect their own programming to be affected -- which was the gist of what I was trying to say in my commentary on the poll results.

When I talked about how long many Java developers have been waiting for closures in Java, and how they've anticipated this enhancement, I was actually switching to talking about history, rather than talking about this specific poll. That's why I say "But getting back to this poll's results..." in the subsequent paragraph. But, perhaps I didn't make this sufficiently clear.

Your comments (along with the comment rdohna posted to the poll) suggest a new poll that asks if developers consider the addition of Lambda Expressions in Java 8 to be a good thing or not. I'll credit you and rdohna with inspiring the idea when I make that poll live!

Brian Goetz Provides an Updated "State of the Lambda: Libraries Edition"

Posted by editor on April 25, 2012 at 7:07 PM PDT

Recently, I've been investigating the methods Java provides for developing desktop applications that efficiently utilize multicore processors. Java 7's Fork/Join Framework is the current focus of my investigation. But, Brian Goetz has just provided an update on the State of the Lambda: Libraries Edition, which tells us lots about the current status of what's coming up in Java 8, where Project Lambda will introduce Lambda Expressions into Java.

It probably shouldn't be a big surprise, but implementing Lambda Expressions in Java 8 is going to have a very wide-ranging impact, on everything from the Collections framework to "laziness" to streams to parallelism to mutative operations... Brian takes the time to go into the details on these and other aspects of Lambda Expressions as the current work on Java 8 is progressing.

Brian states:

This document describes the design approach taken in the rough prototype that has been implemented in the Lambda Project repository. It is intended as a working straw-man proposal; the final version may look different, but there is a working design and implementation that may now serve as a jumping-off point for discussions.

If the implementation of Lambda Expressions in Java 8 is of considerable importance to you, this is a must read. The final implementation is no where near final at this point, and Brian is in essence asking people for suggestions. Take advantage of the offer to comment -- but, first, take the time to read Brian's State of the Lambda: Libraries Edition.


Java.net Weblogs

Since my last blog post, several people have posted new java.net blogs:


Poll

Our current Java.net poll asks . Voting will be open until Friday, April 27.


Java News

Here are the stories we've recently featured in our Java news section:


Spotlights

Our latest Java.net Spotlight is Arun Gupta's Chennai Java Summit 2012 Trip Report:

I attended my first Chennai Java Summit last weekend. The one-day conference had two parallel tracks. The conference was organized as part of AIOUG (All India Oracle User Group) and so there was a parallel track covering Oracle technologies as well...


Subscriptions and Archives: You can subscribe to this blog using the java.net Editor's Blog Feed. You can also subscribe to the Java Today RSS feed and the java.net blogs feed. You can find historical archives of what has appeared the front page of Java.net in the java.net home page archive.

-- Kevin Farnham

Twitter: @kevin_farnham

Related Topics >>

Multithread Programming Versus Parallel Programming; or, What's Wrong with Java Threads?

Posted by editor on April 22, 2012 at 11:46 AM PDT

A few nights ago, I was browsing the chapters about concurrent programming in Herbert Schildt's excellent Java: The Complete Reference, 8th Edition, and I was struck by the evolution of concurrency in Java over the years, from threads, through the richness of Java 5's Concurrency Utilities, and on to Java 7's Fork/Join Framework. The Java language truly has grown, adapted to the changing world, to the innovations of the hardware platforms on which it runs. And, of course, Java 8 will include Lambda Expressions, or "closures" (JSR 335).

One thing I've wondered is: in what ways are Java threads inadequate? Yes, manual thread management is a pain, fraught with potential for trouble, strange difficult-to-reproduce problems, etc. As I wrote in my last blog post, I have personal experience working on an application where the app ran flawlessly on our own corporate development and test platforms, but keeled over onto itself and brought our customer's much faster, more powerful systems to a halt a few minutes after the program was started up. Concurrent programming is a strange universe, indeed.

The Concurrency Utilities made things easier by adding features like java.util.concurrent.atomic, java.util.concurrent.CyclicBarrier, and perhaps most notably java.util.concurrent.ThreadPoolExecutor. So, with all these convenient new java.util.concurrency features making programming using threads easier, why did we need something like the Fork/Join Framework? Why do we think we need Lambda Expressions?

On page 893 of his book, in the section titled "Parallel Programming via the Fork/Join Framework," Herb Schildt explains:

The Fork/Join Framework enhances multithreaded programming in two important ways. First, it simplifies the creation and use of multiple threads. Second, it automatically makes use of multiple processors.

But, from this description, we still don't have a clear idea of what was "wrong" with plain old Java threads, do we?

On the next page, Herb says:

it is important to point out the distinction between traditional multithreading and parallel programming. In the past, most computers had a single CPU and multithreading was primarily used to take advantage of idle time, such as when a program is waiting for user input. Using this approach, one thread can execute while another is waiting... Although this tyupe of multithreading will always remain quite useful, it was not optimized for situations in which two or more CPUs are available (multicore computers).

So, that's the answer to my question. Java threads are not optimized for parallel computing. The Fork/Join Framework is.

Indeed, in his paper "A Java Fork/Join Framework" Doug Lea reports that his Fork/Join implementation of a class that computes the Fibonacci Function "runs at least thirty times faster than an equivalent program in which each new task is run in a new java.lang.Thread." That's a remarkable difference!

I'll be experimenting with the Fork/Join Framework very soon. Among my first tests will be developing Fork/Join Framework implementations of some of the experiments I did earlier with Java threads (documented in my blog posts "Multicore Desktop Application Experimentation, Part 1: Java Threads" and "A Look at Java Thread Overhead"). I'm looking forward to this!


Java.net Weblogs

Since my last blog post, several people have posted new java.net blogs:


Poll

Our current Java.net poll asks Are you aware of Oracle Enterprise Pack for Eclipse (OEPE)?. Voting will be open until Friday, April 27.


Java News

Here are the stories we've recently featured in our Java news section:


Spotlights

Our latest Java.net Spotlight is Geertjan Wielenga's JavaOne Moscow:

JavaOne Moscow has come and gone. I was one of the lucky people able to be there as a speaker, together with several others I've known for some years, including [Duke]. It was a great conference, extremely well attended, people walking around everywhere, going to sessions, booths, and long lines at lunch...

Before that, we featured James L. Weaver's Best Practices for JavaFX 2.0 Enterprise Applications (Part One):

This article, which is part one of a two-part series, focuses on using best practices for developing enterprise applications in JavaFX 2.0. To illustrate some best practices for enterprise application development in JavaFX 2.0, a sample application named TweetBrowser will be examined. As shown in Figure 1, this application contains the following...


Subscriptions and Archives: You can subscribe to this blog using the java.net Editor's Blog Feed. You can also subscribe to the Java Today RSS feed and the java.net blogs feed. You can find historical archives of what has appeared the front page of Java.net in the java.net home page archive.

-- Kevin Farnham

Twitter: @kevin_farnham

Java 7 Fork/Join Framework Initial Look, and Resources

Posted by editor on April 16, 2012 at 9:08 PM PDT

In some earlier posts, I've talked about Java threads, Java Thread Overhead, and Amdahl's Law and Parallel Processing Speed-Up. My next investigation in this series is Java 7's new Fork/Join Framework. I plan to spend quite a lot of time in this particular investigation. For one, Java Threads have been around for a long time, and undoubtedly there are many resources available that discuss them; but the Fork/Join Framework is new, and hence, by spending more time investigating the characteristics of the framework, I'll be helping to provide a roadmap or points for thought/discussion for other developers.

This first post is a basic introduction to the framework, pointing out some of the available resources, outlining the basic concept of the framework, etc.

So, to start with, what do the terms "fork" and "join" mean in this context? If you're a Unix/Linux programmer, you very likely know that the fork command creates a process that is duplicate of itself, known as a "child" process. From there, the two processes can work on different segments of a problem. The results of the processing of the separate segments of the problem can then be "joined" to produce the final product. This approach is advantageous if multiple processes can execute simultaneously, for example on a multiprocessor system like the 8-processor Sun servers I worked with starting in 1993, or on a modern dual- or quad-core desktop PC.

A kind of sad side note: the term "fork" is also used when a group of people takes an open source code base and begins separate development on that code. The same term is used, but unfortunately, in open source development there is no accompanying "join" that rebuilds the accumulated work from the original effort and the "forked" effort into a unified final product. In the open source world, a "fork" is the proverbial "fork in the road" wherein the path taken never reunites with the path foregone...

Anyway, Java 7's Fork/Join Framework is Unix/Linux-like in the manner in which it divies up work, then joins all the subcomponent results into a single unified result. The Fork/Join Tutorial states that:

The fork/join framework is distinct because it uses a work-stealing algorithm. Worker threads that run out of things to do can steal tasks from other threads that are still busy.

This reminds me of Intel's Threading Building Blocks (TBB), a C++ library for achieving parallel processing. I know a lot about TBB, since I was the original editor / community manager for open source TBB back in 2007-2008 when TBB was first open sourced. The "work-stealing" method has a long, and in my view successful, history as a method for making achieving efficient parallel processing that's not terribly taxing on the developer.

Julien Ponge agrees with me on the "not terribly taxing" statement in his OTN article Fork and Join: Java Can Excel at Painless Parallel Programming Too! Julien's article shows that:

rich primitives can be used and assembled to write high-performance programs that take advantage of multicore processors, all without having to deal with low-level manipulation of threads and shared state synchronization.

And, that last phrase is the key: dealing with low-level manipulation of threads and synchronization... If you've ever developed multithread applications in any of the older languages... Put it this way: coping with thread management is bad at the development level. Move to the test/debug level, and it becomes a nightmare. A real-life illustration from my own personal experience:

Big Boss: Your app is producing random results and crashing for our most important client!

Developer: I tested that thoroughly, completely, perfectly, all results were correct in the 18,476 tests I ran on our systems, and there were no crashes!

Big Boss: You're saying our most important customer is lying? Get yourself to their data center ASAP!

... At the customer's data center, the developer realizes the customer's computers are much more high-end than the ones he developed and tested the app on. There is a bug in the thread management, memory overwrites, something that happens on the customer's high-end computers that never happens on the computers on which the multithreaded software was developed and tested... whoa!

Developer (thinking): Now what do I do? Ask the customer if I can develop the fix using their operational system as my test bed? Won't that seem weird to them? But, do I dare do the obvious -- ask Big Boss to buy as high-end computers as our huge-business customer has? But, if miraculously he approved, then I'd have to spend weeks developing a test that simulates Big Customer's data analysis situation. Mightn't they decide to go with IBM's very expensive but proven solution before I can accomplish that???

Those with experience know: managing threads on your own isn't a pretty situation. I've done it, both in creating a custom data center (the safe way, since you can indeed test on the actual computers the software will run on), and in the blockquoted situation, where I was working for a software vendor, and what worked on our computers failed miserably on our big customer's much fancier more high-end systems...

Yes, I've been very deep in the thread trenches (since 1993!). Or, fallen very deep into the trenches? I consider myself a very good programmer, but dealing with native thread management? Please, at this point in my career, can't I just sit back and watch it all happen for me instead? Yeah, manage the threads for me, Fork/Join Framework. I'll take that!

Just to whet your appetite, here are a few more links to articles developers have written about the Fork/Join Framework:

I very much look forward to my upcoming experiments with Java 7's Fork/Join Framework. Stay tuned if this topic interests you!


Java.net Weblogs

Since my last blog post, several people have posted new java.net blogs:


Poll

Our current Java.net poll asks How often do you attend Java conferences?. Voting will be open until Friday, April 20.


Java News

Here are the stories we've recently featured in our Java news section:


Spotlights

Our latest Java.net Spotlight is Heather Van Cura's Recent JSR Updates-JSR 356, 357, 355, 349, 236 :

JSR 357, Social Media API, was not approved by the SE/EE EC to continue development in the JCP program. JSR 356, Java API for WebSocket, was approved by the SE/EE EC to continue development in the JCP program...

Previously, we featured Deepak Vohra's JSF 2.0 for the Cloud, Part One:

JavaServer Faces 2.0 provides features ideally suited for the virtualized computing resources of the cloud. Here, in Part One of a two-part article, we look at @ManagedBean annotation, implicit navigation, and resource handling...


Subscriptions and Archives: You can subscribe to this blog using the java.net Editor's Blog Feed. You can also subscribe to the Java Today RSS feed and the java.net blogs feed. You can find historical archives of what has appeared the front page of Java.net in the java.net home page archive.

-- Kevin Farnham

Twitter: @kevin_farnham

Related Topics >>

Amdahl's Law and the Not-So-Simple Problem of Speed-Up Due to Parallel Processing

Posted by editor on April 9, 2012 at 4:19 PM PDT

With the advent of multicore processors on everything from desktop computers to tablets, pads, and even mobile phones, parallel processing is gaining increasing attention. This is at least in part what's behind the release of the Fork/Join Framework in Java 7, and the inclusion of Lambda Expressions (aka "closures," JSR 335) in the upcoming Java 8.

While the "do-it-yourself" approach to developing an application, or a component of an application, that performs processing in parallel, is fraught with complexity (thread management, etc.) and potential for error (memory overwrites, threads that die, threads that never return...), if you parallelize your code using the Fork/Join Framework or Java 8 Lambda Expressions, much of the overhead associated with thread management will be taken care of for you.

Still, parallelizing your application isn't always as beneficial as you might think. For starters, there's Amdahl's Law, which defines the theoretical limit for speeding up your application, or component, based on the amount of processing that can be parallelized and the amount of parallelization that can be applied. Here's one form of the Amdahl's Law equation:

MaximumSpeedUp = 1 / [(1 - P) + P/N]

where P is the fraction of the total processing that can be parallelized, and N is the parallelization factor. In practice, you can think of N as being the number of processor cores you'll be utilizing for running the parallelized portion of your application.

So, let's look at what this implies...

The plot (from Wikipedia) shows the theoretical maximum realizable speed-up for four different applications (where 50%, 75%, 90%, and 95% of the processing can be parallelized) if the portion of the code that can run in parallel utilizes from 1 to 65536 processor cores.

What you realize pretty quickly is that in all cases there's a limit after which throwing more processors at the problem gains almost nothing that would be noticed by a user of an application. The limit in possible speed-up is readily calculable: set N to infinity, and Amdahl's Equation reduces to:

MaximumSpeedUp = 1 / [1 - P] = 1/S

Here we're defining S as the fraction of the processing that must be run in serial mode (i.e., the part that cannot be parallelized, or 1 - P). From this, you see that the maximum speedup limit is entirely determined by the the portion of the application that must be run in serial mode, using a single processor.

But, Amdahl's Law actually is a simplification of reality. Parallelizing an application component involves processing overhead that does not exist in serial processing. It takes time and processing to divide the task into multiple chunks that can be divied out to the available processors, time and processing to manage the threads/processes as they are running, and time and processing to collate the subresults produced by each of the parallel processes into the data unit that is the final product of the processing.

In A Look at Java Thread Overhead I showed that, using standard Java threads, there is indeed a limit with respect to size of task after which thread overhead comes to occupy more time than the task itself. My point was to show that, indeed, creating threads and joining them back does occupy processing time.

Bringing the additional overhead into Amdahl's Equation, we get something like this:

ActualSpeedUp = 1 / [S + P/N + Ttm + Tdiv + Tjoin]

Where:

  • S is the fraction of the processing that runs serially;
  • P is the fraction of the processing that can be parallelized;
  • N is the number of parallel processes/threads utilized;
  • Ttm is the time spent on thread management;
  • Tdiv is the time spent on dividing the task into N chunks; and
  • Tjoin is the time spent on joining the subresults into the final product unit.

From this you can see that there are many possibilities whereby an application component that has been parallelized might actually take longer to execute than a serial version of the same component.

I'll be writing much more about the topic of parallel processing in the future. This is just a start!


Java.net Weblogs

Since my last blog post, Java.net Community Manager Sonya Barry posted a new java.net blogs:


Poll

Our current Java.net poll asks How often do you attend Java conferences?. Voting will be open until Friday, April 20.


Java News

Here are the stories we've recently featured in our Java news section:


Spotlights

Our latest Java.net href="http://www.java.net/archive/spotlight">Spotlight is Patrick Curran's Merging the Executive Committees:

As I explained in this blog last year, we use the Process to change the Process. The first of three planned JSRs to modify the way the JCP operates (JSR 348: Towards a new version of the Java Community Process) completed in October 2011. That JSR focused on changes to make our process more transparent and to enable broader participation...


Subscriptions and Archives: You can subscribe to this blog using the java.net Editor's Blog Feed. You can also subscribe to the Java Today RSS feed and the java.net blogs feed. You can find historical archives of what has appeared the front page of Java.net in the java.net home page archive.

-- Kevin Farnham

Twitter: @kevin_farnham

JavaOne Call for Papers Ends Monday; Please Don't Wait Until the Last Moment!

Posted by editor on April 6, 2012 at 11:16 PM PDT

It seems not that long ago that the JavaOne 2012 Call for Papers began. Yet, here we are, in the CfP's final weekend! All proposals for JavaOne 2012 sessions must be submitted by 11:59 PM Pacific Daylight Time (US) on Monday. Now, I'm not going to try to compute the equivalent local time for everyone around the world. In my experience, you don't try to submit something like this at the very last minute. What if your internet connection goes down, or a glitch occurs somewhere else? Getting your submission in well before early morning GMT on Tuesday is my advice.

Now, if only I can follow my own advice!

I'm proposing my first ever JavaOne session. We'll see what happens. My proposed session is related to the emergence of multicore desktop computers, tablets/pads, and mobile phones. I plan to go over the history of increases in processing speed, which reached a kind of limit some years ago. Once rapid increases in processing speed in a single processor core were no longer attainable, chip manufacturers started making multicore chips. So, the total processing power per chip continued to increase. But now, instead of the power increasing due to increased processing speed in a single core, the increased power came from multiple cores residing on a single chip.

This, of course, has major implications for applications. If your app is not multithreaded, it will use only one of the processor's cores. So, if someone has a quad-core device, your app will be using only one of those cores if it's not multithreaded. That's fine in some cases, for example for apps that have lots of interaction with the user. It's not fine if your app is computationally intensive. If your competitor develops an app that uses all available processors, their app will have blazing speed compared to yours. Not cool...

So, my proposed session will talk about this history, then get into the problems of multithreaded programming, from a generic, language-neutral viewpoint (remember, I was developing multithreaded apps in C and Fortran on SunOS systems in 1993). Problems like memory overwrites, deadlocks, threads that never complete... the world goes crazy once you get into parallel programming. So, what is "threadsafe" code anyway?

Next, my plan is to talk about the history of parallel processing in the JVM through today. Java has had threads for a very long time. It doesn't seem to me that many developers have actually used them. What was the need? For high-end data center processing, Java EE met the need. In the old single core processor world, what's the difference between a multiprocessor computer (like the 8-processor Sun machines I worked on in the mid 1990s) and a server farm?

But here's the problem: today, many people can pick up and hold in their hand what in the past was a mini data center, a mini server farm -- because, in their hand they can hold 2 or 4 or even 8 processor cores. Now, we're not going to use Java EE to make that fancy, powerful phone or tablet fully utilize all of its processing cores, are we? Well.. my friend Adam Bien might argue "why not?" since Java EE 6 provides such lightweight components.

He's right, Java EE could do the trick. But, the software that we want to utilize all the cores wasn't originally developed using Java EE. A great many of us are not inventing new apps; rather, we're trying to port existing apps into this new multicore world. Surely, we can't take the time to rewrite all that code such that it will efficiently run in a hand-held data center, can we? Does any company have a budget for that? Hence, the need for a path to convert desktop apps designed for operation on single-core processors into apps that can efficiently utilize the multicore processors that reside inside modern desktop computers, tablets, and mobile phones.

So, what about Java threads? I recently did some basic experimentation and found that, in a purely mathematical computational scenario, basic Java threads do a pretty good job of fully utilizing my CentOS Linux quad-core processor. But, basic Java threads don't work well in all scenarios. Hence, the decision to introduce the Fork/Join Framework in Java 7.

Converting existing apps developed for the single-core world is still an enormous amount of work, whether you convert the apps to use Java threads, the Fork/Join Framework, or even Java EE 6. This is what's behind the incredibly ambitious Project Lambda, which will introduce closures in Java 8. The parallelization will be implemented in the underlying Java libraries themselves, removing the need for desktop developers to deal with the damnable headaches associated with parallel programming (those memory overwrites, deadlocks, infinitely wandering threads, etc., that I mentioned above). The desktop app developer will simply have to invoke the underlying parallelism where doing so will increase performance. The complexities of thread management, etc., will all take place "under the hood."

If you can't wait for Java 8, and you're developing a new desktop app (whether your "desktop" is a PC, tablet, or fancy phone), there are multiple non-Java parallel programming options for the JVM that are available right now, in languages like Clojure and Scala.

I'll talk about all of this at JavaOne 2012, if my proposed session is accepted.

So, what do you think? Is this a session you might want to attend if you were at JavaOne 2012? Any suggestions on additional items I should include in my proposal? I have until Monday night to finalize it...


Java.net Weblogs

Since my last blog post, Rex Young posted two new java.net blogs:


Poll

Our current Java.net poll asks How often do you attend Java conferences?. Voting will be open until Friday, April 20.


Java News

Here are the stories we've recently featured in our Java news section:


Spotlights

Our latest Java.net Spotlight is Jonathan Giles's Interview with Jim Weaver and Stephen Chin:

Hi all. I’m currently sitting in a hotel room in Tokyo, but I’ve been waiting to publish this interview until Jim and Steve made their announcements this week. Now that the news of their employment at Oracle is out, here is the interview. Enjoy!...

Previously we featured Joseph D. Darcy's Goto for the Java Programming Language:

Work on JDK 8 is well-underway, but we thought this late-breaking JEP for another language change for the platform couldn't wait another day before being published. Title: Goto for the Java Programming Language...


Subscriptions and Archives: You can subscribe to this blog using the java.net Editor's Blog Feed. You can also subscribe to the Java Today RSS feed and the java.net blogs feed. You can find historical archives of what has appeared the front page of Java.net in the java.net home page archive.

-- Kevin Farnham

Twitter: @kevin_farnham

AttachmentSize
JavaOne2012.png9.6 KB
Related Topics >>

Java User Groups Promote Java Education

Posted by editor on March 31, 2012 at 11:10 PM PDT

Java User Groups are becoming active in educating the next generation of Java developers. In a post to the JUG Leaders email list, the MoroccoJUG stated that they organized "a new program to give Java EE courses to students in their graduation year (from engineering schools and university..)". They call the program JEMI (Java Education Moroccan Initiative).

The curriculum includes:

  • Enterprise application with Java EE6 (Java EE overview)
  • Web Development ( JSP, Servlets); JSF
  • CDI (Context & dependency injection)
  • JPA 2.0; EJB 3.0
  • JAX-WS within the context of Web Services and RESTful Web Services

Pictures are available on the MoroccoJUG Flickr page.

The Pakistan JUG has also "started a 4-session Java EE 6 Workshop in local university,ialamabad,Pakistan to educate students about Java."

The idea of Java User Groups engaging in educating the younger generation of developers is receiving considerable attention on the JUG Leaders email list of late. Java User Group Chennai leader Raj Hegde wonders:

Do we really need multiple version of java material in English (which is a common in many countries) ? If we do so what i see is some very basic change in this... instead of creating multiple English version of Java Education material, why not well first all join and create one single English version and then let regional JUGs can translate this material to their regional language (spanish, french, tamil, hindi etc) I feel this makes sense.!

Makes a lot of sense to me, too. Why not have a "master" version of essential Java material written in English. Then, where needed, involve Java User Groups to provide translations for members of their locality who cannot benefit from the English language edition? This, as opposed to having many different versions of basic Java content produced in various countries...

Raj ends his post with:

We have started wonderful movements in these days "Adopt a JSR" "Adopt OpenJDK" Why not we make something on a common Java English material and then let it be with regional JUG to do in different languages.

Java User Groups have indeed recently become very active in the JCP via the Adopt-A-JSR Program, and they are also increasingly active in Java's future through increased involvement in development of the next generation of the OpenJDK. Educating the next generation of developers does indeed seem a natural extension of these efforts, no?


Java.net Weblogs

Since my last blog post, Rex Young posted new java.net blog:


Java News

Here are the stories we've recently featured in our Java news section:


Spotlights

Our latest Java.net href="http://www.java.net/archive/spotlight">Spotlight is the NetBeans Team's NetBeans IDE 7.1 Satisfaction Survey:

Thank you for taking the time to provide your feedback on your experience with NetBeans IDE 7.1 or the update release NetBeans IDE 7.1.1. Question 1. Are you providing feedback for NetBeans IDE 7.1 or the update release 7.1.1? ...

Our previous Spotlight was Arun Gupta's Jersey 2.0 Milestone 2 Now Available:

Jersey 2.0 milestone 2 is now available. It builds upon the first milestone and adds several new features such as server-side asynchronous processing, server-side content negotiation, improved JAX-RS parameter injection, and several others...

Before that, we featured Emil Ivov's Google Summer of Code 2012 is on! Apply Now!:

This year Jitsi is participating in GSoC under the umbrella of the XMPP Standards Foundation. To all students: check our the Jitsi project ideas and Apply Now!. You can also check the other cool XMPP projects particpating with the XSF. Waste no time, deadline is April 6!


Articles

Our latest Java.net article is Michael Bar-Sinai's PanelMatic 101.


Subscriptions and Archives: You can subscribe to this blog using the java.net Editor's Blog Feed. You can also subscribe to the Java Today RSS feed and the java.net blogs feed. You can find historical archives of what has appeared the front page of Java.net in the java.net home page archive.

-- Kevin Farnham

Twitter: @kevin_farnham

Comments

Nice information and they are doing a great job. Do they ...

Nice information and they are doing a great job. Do they provide online eduction too?

refurbished office cubicles Miami

A great grassroots effort! It's high time we start doing ...

A great grassroots effort!
It's high time we start doing this like MS do with their academic evangelists where they push their .NET tool chains into tertiary education curriculum.

We haven't done enough at this level for Java technologies (at least here in Singapore) and it is no surprise we get a diminishing pool of fresh-blood Java developers, because they were only exposed to .NET environment.

I wish the JUGs all success in this commendable endeavor !

TC