| By Parameswaran Seshan | Article Rating: |
|
| October 16, 2008 08:00 PM EDT | Reads: |
9,557 |
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.
Published October 16, 2008 Reads 9,557
Copyright © 2008 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
More Stories By Parameswaran Seshan
Parameswaran Seshan performs the role of an independent educator/trainer, architect, researcher, and architecture consultant, in Information Technology (IT). He teaches architecture, design and technology related courses. Prior to this, he worked as Principal (Education and Research) with E-Comm Research Lab, Infosys Technologies Limited, Bangalore, India. He has around 15 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, Intelligent agents, software architecture, Business Process Management systems, Web services and Java. You can reach Parameswaran at, contact {at} bitsintune [dot] com.
- It's the Java vs. C++ Shootout Revisited!
- Patterns for Building High Performance Applications
- OpenXava 4.3: Rapid Java Web Development
- Asynchronous Logging Using Spring
- Java for Programmers (2nd Edition)
- Cross-Platform Mobile Website Development – a Tool Comparison
- Write Once Run Anywhere or Cross Platform Mobile Development Tools
- Three Buzzwords That Every CIO Hears but One They Should Listen To
- Immersing into JavaScript Frameworks
- Workday Reportedly Prepping to Go Public
- Book Review: Sams Teach Yourself Java in 24 Hours
- Cloud Expo New York: The Java EE 7 Platform - Developing for the Cloud
- Book Excerpt: Introducing HTML5
- Adobe Sends Flex to the Apache Foundation
- Five Years Waiting for JRE 7: Is It Justified? (Part 1)
- Book Excerpt: Java Application Profiling Tips and Tricks
- i-Technology in 2012: Five Industry Predictions
- It's the Java vs. C++ Shootout Revisited!
- Patterns for Building High Performance Applications
- OpenXava 4.3: Rapid Java Web Development
- The Next Web Architecture
- Asynchronous Logging Using Spring
- Java for Programmers (2nd Edition)
- Is Write Once Run Anywhere Ever Going to Be a Reality?
- A Cup of AJAX? Nay, Just Regular Java Please
- Java Developer's Journal Exclusive: 2006 "JDJ Editors' Choice" Awards
- JavaServer Faces (JSF) vs Struts
- The i-Technology Right Stuff
- Rich Internet Applications with Adobe Flex 2 and Java
- Java vs C++ "Shootout" Revisited
- Bean-Managed Persistence Using a Proxy List
- Reporting Made Easy with JasperReports and Hibernate
- Creating a Pet Store Application with JavaServer Faces, Spring, and Hibernate
- Why Do 'Cool Kids' Choose Ruby or PHP to Build Websites Instead of Java?
- What's New in Eclipse?
- i-Technology Predictions for 2007: Where's It All Headed?















