add methods removehead and addtail in connection threads