added ConnectionThread main loop