Read Digital Edition


ADS BY GOOGLE
Top Three Links You Must Click On


Achieving Thread Synchronization & Parallelized Execution in Java
Building multithreaded execution capabilities in a Java application

Applications that have high performance as a quality goal would motivate a programmer to design and build them as multithreaded apps. The Java programming environment provides for parallel execution of logic by using threads. However, this is at a lower level and provides limited capability.

To make multithreading work successfully in an application, programmers have to handle higher-level concerns like synchronizing the execution of multiple threads, handling exceptions in threads executing in parallel, limiting the number of threads in the runtime environment, and thread pooling. Java programmers need an easy-to-use, standardized, trusted, and efficient library to take care of concurrent programming. The concurrent utility developed by Doug Lea is a very popular and useful library for this purpose. By taking the example of a BPMS process execution platform's implementation, we'll look at how we could use the concurrent utility's classes to build a multi-threaded application. This is based on my experience designing and building a BPMS server in Java.

One scenario where concurrent programming is very important is in a business process management system (BPMS). The runtime part of a BPMS, generally referred to as the BPMS server, handles the execution or automation of business processes. In this article, let's look at how we could use the concurrent utility's classes to build a multithreaded application by using a BPMS process execution platform based on my experience in designing and building the same in Java as an example.

Concurrent Utility
Doug Lea, a professor at the State University of New York (SUNY) at Oswego, created a concurrent library (util.concurrent package) in the late '90s that could help handle multithreaded scenarios in Java applications and he made the library openly available. It became so popular with Java programmers that it was included in Java 5.0 (JDK 1.5) as the Java.util.concurrent package. For concurrent programming, it defines a few interfaces and provides their implementations, which are efficient, well-tested, and standardized. The last version prior to its inclusion in JDK 1.5 was util.concurrent 1.3.4. This was the version that we originally used while building our BPMS, since BPMS was based on JDK1.4. To make the future migration to JDK1.5 easier, we subsequently replaced the 1.3.4 release of the concurrent library with the backport of the main java.util.concurrent Java 5.0 classes made available by Dawid Kurzyniec. The package name for the backport is edu.emory.mathcs.backport.Java.util.concurrent.

At a broad level, the library provides the following components: an executor for thread-based execution, synchronizers that aid in synchronizing thread executions, queues that are thread-safe and scalable, concurrent collections, and timing for time handling. From these, we used wxecutor and synchronizers heavily in the BPMS runtime platform and I will explain the usage details in subsequent sections. Executor is used to execute tasks in threads; we could run the task in a separate thread (new) or run the task in the same thread as the current one. ThreadPoolExecutor is an executor implementation that executes the task by utilizing a thread from the managed thread pool. This gives better performance due to the reduced overhead; it also manages the resources (threads) better including bounding them.

About Parameswaran Seshan
Parameswaran Seshan is a Senior architect with E-Comm Research Lab, Infosys Technologies Limited, Bangalore, India. He has around 14 years of work experience in the IT industry, involving research, teaching, architecture, and programming. His areas of interest include Process-centric architecture, Intelligent software systems, software architecture, Business Process Management systems, Web services and Java.

In order to post a comment you need to be registered and logged in.

Register | Sign-in

Reader Feedback: Page 1 of 1

  Subscribe to our RSS feeds now and receive the next article instantly!
In It? Reprint It! Contact advertising(at)sys-con.com to order your reprints!
Subscribe to the World's Most Powerful Newsletters

ADS BY GOOGLE
This past weekend I set out explore some of the extension capabilities of Google Wave. One of the we...
More good news for cloud computing! Google last week released its once mysterious Chrome Operating S...
There's a lot of talk about how we need to focus on our buyers' issues and provide them educational ...
SugarCRM, the world’s leading provider of open source customer relationship management (CRM) softwa...
In CloudBerry Lab we are striving to make our customer service better. In this competitive market wi...
We talk a lot about social media on Marketing Trenches. And for good reason – Social media seems to...
Intel has put out its promised beta SDK for Windows (C and C++) and Moblin (C) developers working on...
InformationWeek stumbled on a Microsoft patent application dating back to 2006 deceptively titled “M...
Berlin-based ThinPrint AG, the printer virtualization house, thinks it’s got a cloud solution for th...
IBM has acquired Guardium, a seven-year-old subsidiary of Israel’s Log-On Software transplanted to M...
But on the web, access to services is implicit in the fact that the business is offering the service...
Behaving like it’s got a future, Sun Monday put out what it calls a significant new version of Virtu...
Oracle has offered to cordon off MySQL inside a combined Oracle-Sun to get the European Commission t...
The second set of charges filed last week against Indian outsourcer Satyam Computer Services founder...
Gartner told Reuters that it overestimated how many PCs Acer shipped in the last seven quarters by a...
Office Web Apps, Microsoft’s answer to Google Apps, are supposed to be out sometime in June along wi...
Gartner thinks the server business has stopped sliding into the abyss. Third-quarter sales weren’t a...
Gartner is buying ~$40 million-a-year AMR Research Inc for close to $64 million in cash. AMD special...
Singed by user reaction to its plans to up the price of its support contracts, SAP Tuesday postponed...
Apparently Google Gears ain’t gonna stick around that long. Google Apps will eventually get their of...