How to Build a Thread-Safe Class