apply mutext to sync gui thread and socket thread