All java collections overview. Comparison is made by the following characteristics:

  1. Backed by — what data structure or collection is used under the hood
  2. Duplicates — whether duplicate values are allowed in collection
  3. Nulls allowed — whether collection allows inserting nulls
  4. Syncronized — are all methods of the collection syncronized or not
  5. Thread-safe — whether it’s safe to use this collection in a multi-threaded environment
  6. Iterator type — iterator behaviour in multi-threaded environment
Java collections overview

Iterator types explained:

  1. fail-fast — iterator saves a collection’s “generation number” on creation, which is basically the number of changed made to collection. During the iteration it…


Distributed locking

Distributed locks are primitives that help you control access to the resource that is shared between different processes. In modern cloud-based applications processes are usually distributed between multiple physical machines.

Redis provides a great opportunities for implementing distributed locking. It’s fast (in cloud you can archive sub-millisecond response time), and it provides atomic execution guarantees for LUA scripts.

Redisson locks

The most popular Java Redis client library that implements distributed locking algorithms is Redisson (lock docs).

Mainly Redisson lock implementations rely on Redis’s pubsub mechanism. Basically, their algorithm can be described as following:

  1. Try aquire a lock by…

Danila Varatyntsev

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store