Make a couple of changes to help improve server performance:
- Update the server code to replace simple uses of ReentrantLock involving
{lock, doSomething, unlock} in the same method to use the synchronized
keyword instead of a ReentrantLock object. Using the synchronized keyword is
actually a little faster, and also simplifies the code since it's no longer
necessary to use a finally block to ensure that the lock is released.
- Update the AsynchronousTextWriter to use the LinkedBlockingQueue.drainTo()
method to attempt to get multiple messages at once, rather than always using
poll() to get one message at a time.