Implemented two-thread solution with coalescing