twitter/util — pull request #102 by sirmax (2014-06-09 22:27:38+00:00)
Title: Thread-safe Event()

Fixes #101

Problem
[`Event[T]()`](https://github.com/twitter/util/blob/192a134/util-core/src/main/scala/com/twitter/util/Event.scala#L284) creates an instance that maintains a list of registered witnesses in `@volatile var registerrs`. The updates to this var are neither atomic nor synchronized. As a result adding/closing a witness is not guaranteed to execute successfully.

Solution
Use atomic operations to update witnesses list. Also add synchronization to `notify()` to avoid out-of-order notifications.