Introduced a mediator thread to communicate with UI thread and communication threads