wamblee.org

Table of contents

This document explains the requirements and the design of a concurrency framework.

Introduction

Even though concurrency support is provided as part the Java platform standard edition, this support focusses only on concurrency within a single virtual machine. Therefore, separate concurrency support is required that can be used transparently within a standard single JVM environment as well as in a clustered environment. The current concurrency support is implemented only for a single JVM, but implementations for a clustered environment are also possible.

The current functionality is really small. It will be extended as soon as more concurrency problems are found.

Requirements

  1. It shall be possible to use reentrant pessimistic locks in a platform independent manner, regardless of whether a clustered environment is used or not.

Design

To cover the requirements Lock interface is provided which is the interface for a single reentrant pessimistic lock. There is one impkementation of this lock for within a single JVM environment. It is possible also to provide a lock which is suitable within a clustered environment.

Structure

Package Overview

Concurrency support is provided in a single package.

Package overview.

Locking

The JvmLock class is the implementation of the Lock interface for within a single JVM environment. It uses the standard ReentrantLock class from the Java runtime environment for its implementation. In addition, a LockAdvice class is present by which method invocations can be automatically guarded by a lock using AOP.

Lock interface and implementation.

Dynamics

Since the current design is trivial, no sequence diagrams are provided.

Design Rules

To use the concurrency support effectively, the following rules should be followed:

  • Beware that pessimistic locking is not suitable for cases with high concurrency, especially when used in a clustered environment. In cases of high concurrency, consider alternative approaches to pessimistic locking, such as optimistic locking or serialization in combination with batch processing.