|
SYS-CON Magazines
|
Top Three Links You Must Click On
General Java Achieving Thread Synchronization & Parallelized Execution in Java
Building multithreaded execution capabilities in a Java application
Oct. 16, 2008 08:00 PM
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 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 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. Reader Feedback: Page 1 of 1
Subscribe to our RSS feeds now and receive the next article instantly!
Subscribe to the World's Most Powerful Newsletters
|
|
||||||||||||||||||||||||||||||||||