Game Instructions

Tap a tile to toggle its color. When a tile changes nearby tiles may change as well. Each move affect multiple tiles. The target is to turn all tiles into yellow in the fewest steps possible.

Press 'j' to show/hide the game. Press 'i' to show/hide the instructions. Press 't' to show/hide the top score table.

Steps: 0

Top Scores

Name Steps
Press J to toggle the game, I to toggle instructions, and T to toggle the top scores

Congratulations!

You solved the puzzle in 0 steps!

Success!

Score submitted successfully!

Error

Failed to submit score. Please try again.

Working with CopyOnWriteArrayList in Java

The CopyOnWriteArrayList Class
The CopyOnWriteArrayList class is a thread-safe collection designed for cases in which reads are frequent and modifications are relatively rare. Its copy-on-write strategy makes iteration simple and safe, but writes come with an additional cost.

The Java programming language provides several concurrent collections for applications in which multiple threads access shared data. The CopyOnWriteArrayList class is one of them. 

What Does Copy on Write Means?

When instantiating the CopyOnWriteArrayList class, we get a list, that its elements are internally stored in an array. Whenever the list is modified, a new copy of that array is created and updated accordingly (instead of changing the existing array directly). Once the modifications are completed, the list starts using the new array (instead of the old one). 

Typical Use Cases

Using theCopyOnWriteArrayList class fits best when using collections, such as:

  • event listeners
  • subscribers
  • observers
  • configuration listeners
  • callback registrations
  • relatively stable shared lists

These collections often change rarely but are read repeatedly by many threads.

The Main Trade-Off

The design of CopyOnWriteArrayList deliberately exchanges write performance for simpler and safer concurrent reads.

The Internal Lock

TheCopyOnWriteArrayList class uses an internal lock for mutating operations such as add() and remove(). If a thread tries to add or remove an item that thread will hold the lock which will prevent any other thread to add or remove an item at the same time. 

When many threads frequently read a relatively stable list, using the CopyOnWriteArrayList can be an excellent choice. When modifications are frequent, a different concurrent collection or synchronization strategy might be more suitable.

Share:

Sofia Bulgaria

Sharing My Experience at WordCamp Sofia 2026

Sharing highlights from my talk at WordCamp Sofia 2026, exploring practical WordPress hardening techniques, stronger authentication, and the importance of layered security beyond WAF protection.

online conference

Sharing My Experience at All Day AI 2026

It was an inspiring day of discussions about AI, excellent organization, and engaging conversations on discord. It was a great opportunity for sharing my perspective about Spec-Driven Development.

The Beauty of Code

Coding is Art! Developing Code That Works is Simple. Develop Code with Style is a Challenge!

Update cookies preferences