print output in a separate thread