How I Used the Observer Pattern to Watch Directories in Java (And Prevent Race Conditions)
Java's WatchService makes directory watching straightforward — but spin up a thread pool and you've got a race condition waiting to corrupt your data. Here's how I used the Observer pattern and per-path ReentrantLocks to fix it.