add multhread support for client