# Locking

Author: Eike Stepper

This chapter describes the locking mechanisms available in CDO client applications, including lock types and strategies for managing concurrent access to model data. Locking is essential for ensuring data integrity and consistency in collaborative environments.

## 1 Lock Types

CDO supports several types of locks to control access to model objects. This section explains the differences between read locks, write locks, and write option locks, and how to use them to prevent conflicts and ensure safe modifications.

### 1.1 Read Locks

Read locks allow multiple clients to access model objects concurrently for reading, while preventing modifications. Learn how to acquire and release read locks to enable safe, concurrent navigation of repository data.

### 1.2 Write Locks

Write locks provide exclusive access to model objects for modification. This section covers how to obtain write locks, handle lock contention, and release locks after changes are committed.

### 1.3 Write Option Locks

Write option locks are a specialized form of locking that allow clients to prepare for future write operations. Learn how to use write option locks to optimize transaction workflows and reduce lock contention.

## 2 Optimistic Locking

Optimistic locking assumes that conflicts are rare and allows clients to proceed with changes without acquiring locks up front. This section explains how optimistic locking works in CDO, how to detect and resolve conflicts at commit time, and best practices for using optimistic strategies.

## 3 Pessimistic Locking

Pessimistic locking requires clients to acquire locks before making changes, preventing other clients from modifying the same objects concurrently. Learn how to implement pessimistic locking in CDO, manage lock lifecycles, and avoid deadlocks.

## 4 Durable Locking

Durable locks persist across client disconnects and server restarts, ensuring long-term protection of model objects. This section covers how to create, manage, and release durable locks, and when to use them in your application.

Copyright (c) 2004-2026 Eike Stepper (Loehne, Germany) and others.
All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html