threads working with random ports