Use a blocking queue instead of manually synchronizing.