Author prefers to remain anonymous.
If you studied computer science, you're probably familiar with the Dining Philosopher problem . On one project I was working on, I had to have my new Java technology-based Web application communicate with legacy systems. These legacy systems only communicated using an asynchronous protocol, but fortunately there was C API I could use. However, the API was written for a non-threaded environment. I spent some time making a JNI thread-safe communication mechanism so my threaded Java code could communicate with the legacy resources, and I made sure to lock common resources when they were being used.